[PyTorch] Use real if constexpr behind macro in hot template (#51368)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51368
This seems to noticably reduce build times, at least for
RegisterCPU.cpp. It makes sense that a compiler builtin would be
faster than simulating the same builtin with templates.
Identified with templight.
ghstack-source-id: 121378959
Test Plan:
Confirmed this speeds up RegisterCPU.cpp optimized build by
simply running builds under `time(1)`:
previous diff: [50.53, 50.41, 50.57, 50.67, 50.94]
mean: 50.6 std: 0.179
this diff: [45.71, 45.89, 46.21, 48.51, 45.84]
mean: 46.4 std: 1.05
Reviewed By: bhosmer
Differential Revision: D26154964
fbshipit-source-id: 62ee2f5a872007db032dfebf7ad4d1b6e1ce63d1