Support the % N
-> & (N - 1)
transformation for runtime power-of-two values
#58996
Labels
% N
-> & (N - 1)
transformation for runtime power-of-two values
#58996
I tried sending this to opt
expecting it to optimize to something like this
but it didn't -- it left the
div
in the generated assembly.Alive2 proof that this would be fine: https://alive2.llvm.org/ce/z/irgU2q
If there's a better way to communicate this, then please let me know! Assuming ctpop seemed like the best way, though, since
x & (x - 1) == 0
gets normalized down toctpop <= 1
, and thus I assumed that it was the preferred way to tell LLVM the value is a power-of-two.The text was updated successfully, but these errors were encountered: