[PATCH] Added InstCombine for ((1 << X) & C) pattern
Dinesh Dwivedi
dinesh.d at samsung.com
Sat May 31 13:11:53 PDT 2014
================
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));
+ }
}
----------------
Benjamin Kramer wrote:
> 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.
done
================
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));
+ }
}
----------------
Benjamin Kramer wrote:
> Same here.
This is already using ULT. Updated code to have symmetry with ICMP_EQ case.
http://reviews.llvm.org/D3678
More information about the llvm-commits
mailing list