[PATCH] Added InstCombine for ((1 << X) & C) pattern
Benjamin Kramer
benny.kra at gmail.com
Sat May 31 05:48:43 PDT 2014
This is going into the right direction, thanks. One minor tweak left.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2542-2550
@@ -2541,1 +2541,11 @@
+
+ if (!ValToCheck.isPowerOf2()) {
+ Pred = ICmpInst::ICMP_UGE;
+ ++ValToCheck;
+ }
+
+ if (ValToCheck.isPowerOf2()) {
+ unsigned CVal = ValToCheck.countTrailingZeros();
+ return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), CVal));
+ }
}
----------------
I think it would be better to generate an ICMP_UGT directly instead of emitting an ICMP_UGE which is turned into ugt later on.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2589-2597
@@ -2578,1 +2588,11 @@
+
+ if (!ValToCheck.isPowerOf2()) {
+ Pred = ICmpInst::ICMP_ULT;
+ ++ValToCheck;
+ }
+
+ if (ValToCheck.isPowerOf2()) {
+ unsigned CVal = ValToCheck.countTrailingZeros();
+ return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), CVal));
+ }
}
----------------
Same here.
http://reviews.llvm.org/D3678
More information about the llvm-commits
mailing list