[PATCH] D69942: [ConstantRange][LVI] Use overflow flags from `sub` to constrain the range

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 7 05:23:40 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG69ce2ae990e7: [ConstantRange][LVI] Use overflow flags from `sub` to constrain the range (authored by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69942/new/

https://reviews.llvm.org/D69942

Files:
  llvm/lib/IR/ConstantRange.cpp
  llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll


Index: llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
===================================================================
--- llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
+++ llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
@@ -490,11 +490,9 @@
 ; CHECK-NEXT:    [[SUB:%.*]] = sub nuw nsw i32 [[A]], [[B]]
 ; CHECK-NEXT:    br label [[CONT:%.*]]
 ; CHECK:       cont:
-; CHECK-NEXT:    [[RES:%.*]] = icmp sge i32 [[SUB]], 0
 ; CHECK-NEXT:    br label [[EXIT]]
 ; CHECK:       exit:
-; CHECK-NEXT:    [[IV:%.*]] = phi i1 [ true, [[BEGIN:%.*]] ], [ [[RES]], [[CONT]] ]
-; CHECK-NEXT:    ret i1 [[IV]]
+; CHECK-NEXT:    ret i1 true
 ;
 begin:
   %cmp0 = icmp sge i32 %a, 0
@@ -598,11 +596,9 @@
 ; CHECK-NEXT:    [[SUB:%.*]] = sub nsw i32 [[A]], [[B]]
 ; CHECK-NEXT:    br label [[CONT:%.*]]
 ; CHECK:       cont:
-; CHECK-NEXT:    [[RES:%.*]] = icmp sle i32 [[SUB]], 0
 ; CHECK-NEXT:    br label [[EXIT]]
 ; CHECK:       exit:
-; CHECK-NEXT:    [[IV:%.*]] = phi i1 [ true, [[BEGIN:%.*]] ], [ [[RES]], [[CONT]] ]
-; CHECK-NEXT:    ret i1 [[IV]]
+; CHECK-NEXT:    ret i1 true
 ;
 begin:
   %cmp0 = icmp sle i32 %a, 0
Index: llvm/lib/IR/ConstantRange.cpp
===================================================================
--- llvm/lib/IR/ConstantRange.cpp
+++ llvm/lib/IR/ConstantRange.cpp
@@ -824,6 +824,8 @@
   switch (BinOp) {
   case Instruction::Add:
     return addWithNoWrap(Other, NoWrapKind);
+  case Instruction::Sub:
+    return subWithNoWrap(Other, NoWrapKind);
   default:
     // Don't know about this Overflowing Binary Operation.
     // Conservatively fallback to plain binop handling.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69942.228224.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191107/ff4c2d07/attachment.bin>


More information about the llvm-commits mailing list