[PATCH] D60791: [CVP] Simplify umulo and smulo that cannot overflow
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 13:35:50 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358521: [CVP] Simplify umulo and smulo that cannot overflow (authored by nikic, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60791?vs=195435&id=195449#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60791/new/
https://reviews.llvm.org/D60791
Files:
llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
llvm/trunk/test/Transforms/CorrelatedValuePropagation/overflows.ll
Index: llvm/trunk/test/Transforms/CorrelatedValuePropagation/overflows.ll
===================================================================
--- llvm/trunk/test/Transforms/CorrelatedValuePropagation/overflows.ll
+++ llvm/trunk/test/Transforms/CorrelatedValuePropagation/overflows.ll
@@ -507,9 +507,11 @@
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[X:%.*]], 10000
; CHECK-NEXT: br i1 [[CMP]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.false:
-; CHECK-NEXT: [[MULO:%.*]] = tail call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[X]], i32 100)
-; CHECK-NEXT: [[RES:%.*]] = extractvalue { i32, i1 } [[MULO]], 0
-; CHECK-NEXT: [[OV:%.*]] = extractvalue { i32, i1 } [[MULO]], 1
+; CHECK-NEXT: [[MULO1:%.*]] = mul nuw i32 [[X]], 100
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { i32, i1 } undef, i32 [[MULO1]], 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { i32, i1 } [[TMP0]], i1 false, 1
+; CHECK-NEXT: [[RES:%.*]] = extractvalue { i32, i1 } [[TMP1]], 0
+; CHECK-NEXT: [[OV:%.*]] = extractvalue { i32, i1 } [[TMP1]], 1
; CHECK-NEXT: br i1 [[OV]], label [[TRAP:%.*]], label [[COND_END]]
; CHECK: trap:
; CHECK-NEXT: tail call void @llvm.trap()
@@ -545,9 +547,11 @@
; CHECK-NEXT: [[CMP3:%.*]] = or i1 [[CMP1]], [[CMP2]]
; CHECK-NEXT: br i1 [[CMP3]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.false:
-; CHECK-NEXT: [[MULO:%.*]] = tail call { i32, i1 } @llvm.smul.with.overflow.i32(i32 [[X]], i32 100)
-; CHECK-NEXT: [[RES:%.*]] = extractvalue { i32, i1 } [[MULO]], 0
-; CHECK-NEXT: [[OV:%.*]] = extractvalue { i32, i1 } [[MULO]], 1
+; CHECK-NEXT: [[MULO1:%.*]] = mul nsw i32 [[X]], 100
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { i32, i1 } undef, i32 [[MULO1]], 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { i32, i1 } [[TMP0]], i1 false, 1
+; CHECK-NEXT: [[RES:%.*]] = extractvalue { i32, i1 } [[TMP1]], 0
+; CHECK-NEXT: [[OV:%.*]] = extractvalue { i32, i1 } [[TMP1]], 1
; CHECK-NEXT: br i1 [[OV]], label [[TRAP:%.*]], label [[COND_END]]
; CHECK: trap:
; CHECK-NEXT: tail call void @llvm.trap()
Index: llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -400,15 +400,10 @@
// See if we can prove that the given overflow intrinsic will not overflow.
static bool willNotOverflow(WithOverflowInst *WO, LazyValueInfo *LVI) {
- // TODO: Also support multiplication.
- Instruction::BinaryOps BinOp = WO->getBinaryOp();
- if (BinOp == Instruction::Mul)
- return false;
-
Value *RHS = WO->getRHS();
ConstantRange RRange = LVI->getConstantRange(RHS, WO->getParent(), WO);
ConstantRange NWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
- BinOp, RRange, WO->getNoWrapKind());
+ WO->getBinaryOp(), RRange, WO->getNoWrapKind());
// As an optimization, do not compute LRange if we do not need it.
if (NWRegion.isEmptySet())
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60791.195449.patch
Type: text/x-patch
Size: 3128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190416/e4bf34f8/attachment.bin>
More information about the llvm-commits
mailing list