[PATCH] D21440: Use m_APInt in SimplifyCFG

Thomas Jablin via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 11:44:42 PDT 2016


tjablin created this revision.
tjablin added reviewers: majnemer, cycheng.
tjablin added a subscriber: llvm-commits.

Switch from m_Constant to m_APInt per David's request. NFC.

http://reviews.llvm.org/D21440

Files:
  lib/Transforms/Utils/SimplifyCFG.cpp

Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -442,7 +442,7 @@
     }
 
     Value *RHSVal;
-    ConstantInt *RHSC;
+    const APInt *RHSC;
 
     // Pattern match a special case
     // (x & ~2^z) == y --> x == y || x == y|2^z
@@ -487,8 +487,8 @@
         );
       */
       if (match(ICI->getOperand(0),
-                m_And(m_Value(RHSVal), m_ConstantInt(RHSC)))) {
-        APInt Mask = ~RHSC->getValue();
+                m_And(m_Value(RHSVal), m_APInt(RHSC)))) {
+        APInt Mask = ~*RHSC;
         if (Mask.isPowerOf2() && (C->getValue() & ~Mask) == C->getValue()) {
           // If we already have a value for the switch, it has to match!
           if (!setValueOnce(RHSVal))
@@ -519,8 +519,8 @@
     // Shift the range if the compare is fed by an add. This is the range
     // compare idiom as emitted by instcombine.
     Value *CandidateVal = I->getOperand(0);
-    if (match(I->getOperand(0), m_Add(m_Value(RHSVal), m_ConstantInt(RHSC)))) {
-      Span = Span.subtract(RHSC->getValue());
+    if (match(I->getOperand(0), m_Add(m_Value(RHSVal), m_APInt(RHSC)))) {
+      Span = Span.subtract(*RHSC);
       CandidateVal = RHSVal;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21440.61001.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160616/45e3d2a4/attachment.bin>


More information about the llvm-commits mailing list