[PATCH] Added InstCombine for ((1 << X) & C) pattern

Benjamin Kramer benny.kra at gmail.com
Fri May 9 15:06:23 PDT 2014


Getting the cases from Chris' note right is great. However, I don't think
  (X == lg(C)) ? (1 << X) : 0
is preferable to
  (1 << X) & C
in the general case. You're trading a shift + and for icmp + shift + select here. That's more complex and select tends to be an expensive operation. Can you try a more direct way, for example by starting at the icmp operation in instcombine and matching the operands?

http://reviews.llvm.org/D3678






More information about the llvm-commits mailing list