[PATCH] D21417: Fix Side-Conditions in SimplifyCFG for Creating Switches from InstCombine And Mask'd Comparisons

Thomas Jablin via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 18:40:47 PDT 2016


tjablin added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:475-476
@@ -438,5 +474,4 @@
       if (match(ICI->getOperand(0),
                 m_And(m_Value(RHSVal), m_ConstantInt(RHSC)))) {
-        APInt Not = ~RHSC->getValue();
-        if (Not.isPowerOf2() && C->getValue().isPowerOf2() &&
-            Not != C->getValue()) {
+        APInt Mask = ~RHSC->getValue();
+        if (Mask.isPowerOf2() && (C->getValue() & ~Mask) == C->getValue()) {
----------------
majnemer wrote:
> Could we use `m_APInt` here?
Yes. After this is committed, I will prepare an NFC patch with the changes you requested.


http://reviews.llvm.org/D21417





More information about the llvm-commits mailing list