[llvm] r275273 - [ConstantFolding] Use sdiv_ov

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 08:53:47 PDT 2016


Author: majnemer
Date: Wed Jul 13 10:53:46 2016
New Revision: 275273

URL: http://llvm.org/viewvc/llvm-project?rev=275273&view=rev
Log:
[ConstantFolding] Use sdiv_ov

This is a simplification, there should be no functional change.

Modified:
    llvm/trunk/lib/Analysis/ConstantFolding.cpp

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=275273&r1=275272&r2=275273&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed Jul 13 10:53:46 2016
@@ -850,13 +850,13 @@ Constant *SymbolicallyEvaluateGEP(const
         // index for this level and proceed to the next level to see if it can
         // accommodate the offset.
         NewIdxs.push_back(ConstantInt::get(IntPtrTy, 0));
-      } else if (ElemSize.isAllOnesValue()) {
-        // Avoid signed overflow.
-        break;
       } else {
         // The element size is non-zero divide the offset by the element
         // size (rounding down), to compute the index at this level.
-        APInt NewIdx = Offset.sdiv(ElemSize);
+        bool Overflow;
+        APInt NewIdx = Offset.sdiv_ov(ElemSize, Overflow);
+        if (Overflow)
+          break;
         Offset -= NewIdx * ElemSize;
         NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));
       }




More information about the llvm-commits mailing list