[llvm] 9fac849 - [NFC] Detect IV increment expressed as uadd_with_overflow and usub_with_overflow

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 28 22:32:24 PST 2021


Author: Max Kazantsev
Date: 2021-03-01T13:24:01+07:00
New Revision: 9fac8496eae809c288096037d7a3f5a1a3d04c7a

URL: https://github.com/llvm/llvm-project/commit/9fac8496eae809c288096037d7a3f5a1a3d04c7a
DIFF: https://github.com/llvm/llvm-project/commit/9fac8496eae809c288096037d7a3f5a1a3d04c7a.diff

LOG: [NFC] Detect IV increment expressed as uadd_with_overflow and usub_with_overflow

Current callers do not call it with such argument, so this is NFC.
But for further changes, it can be very useful to detect such cases.

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 2c2f667b0c93..d87d5000ec0a 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1293,6 +1293,12 @@ getIVIncrement(const PHINode *PN, const LoopInfo *LI) {
     return std::make_pair(IVInc, ConstantExpr::getNeg(Step));
   if (match(IVInc, m_Add(m_Specific(PN), m_Constant(Step))))
     return std::make_pair(IVInc, Step);
+  if (match(IVInc, m_ExtractValue<0>(m_Intrinsic<Intrinsic::usub_with_overflow>(
+                       m_Specific(PN), m_Constant(Step)))))
+    return std::make_pair(IVInc, ConstantExpr::getNeg(Step));
+  if (match(IVInc, m_ExtractValue<0>(m_Intrinsic<Intrinsic::uadd_with_overflow>(
+                       m_Specific(PN), m_Constant(Step)))))
+    return std::make_pair(IVInc, Step);
   return None;
 }
 


        


More information about the llvm-commits mailing list