[PATCH] D62822: [LVI][CVP] Add support for urem, srem and sdiv
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 14:21:02 PDT 2019
nikic updated this revision to Diff 202798.
nikic added a comment.
Remove ConstantRange::binaryOp() assertion.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62822/new/
https://reviews.llvm.org/D62822
Files:
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
Index: llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
===================================================================
--- llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
+++ llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
@@ -931,7 +931,7 @@
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[UREM]], 30
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: exit:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 true
;
entry:
%urem = urem i32 %a, 30
@@ -949,9 +949,9 @@
; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[SREM]], -30
; CHECK-NEXT: br i1 undef, label [[EXIT1:%.*]], label [[EXIT2:%.*]]
; CHECK: exit1:
-; CHECK-NEXT: ret i1 [[CMP1]]
+; CHECK-NEXT: ret i1 true
; CHECK: exit2:
-; CHECK-NEXT: ret i1 [[CMP2]]
+; CHECK-NEXT: ret i1 true
;
entry:
%srem = srem i32 %a, 30
@@ -972,9 +972,9 @@
; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[SREM]], -17459217
; CHECK-NEXT: br i1 undef, label [[EXIT1:%.*]], label [[EXIT2:%.*]]
; CHECK: exit1:
-; CHECK-NEXT: ret i1 [[CMP1]]
+; CHECK-NEXT: ret i1 true
; CHECK: exit2:
-; CHECK-NEXT: ret i1 [[CMP2]]
+; CHECK-NEXT: ret i1 true
;
entry:
%srem = sdiv i32 %a, 123
Index: llvm/lib/Analysis/LazyValueInfo.cpp
===================================================================
--- llvm/lib/Analysis/LazyValueInfo.cpp
+++ llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1082,31 +1082,18 @@
assert(BO->getOperand(0)->getType()->isSized() &&
"all operands to binary operators are sized");
-
- // Filter out operators we don't know how to reason about before attempting to
- // recurse on our operand(s). This can cut a long search short if we know
- // we're not going to be able to get any useful information anyways.
- switch (BO->getOpcode()) {
- case Instruction::Add:
- case Instruction::Sub:
- case Instruction::Mul:
- case Instruction::UDiv:
- case Instruction::Shl:
- case Instruction::LShr:
- case Instruction::AShr:
- case Instruction::And:
- case Instruction::Or:
- return solveBlockValueBinaryOpImpl(BBLV, BO, BB,
- [BO](const ConstantRange &CR1, const ConstantRange &CR2) {
- return CR1.binaryOp(BO->getOpcode(), CR2);
- });
- default:
- // Unhandled instructions are overdefined.
+ if (BO->getOpcode() == Instruction::Xor) {
+ // Xor is the only operation not supported by ConstantRange::binaryOp().
LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName()
<< "' - overdefined (unknown binary operator).\n");
BBLV = ValueLatticeElement::getOverdefined();
return true;
- };
+ }
+
+ return solveBlockValueBinaryOpImpl(BBLV, BO, BB,
+ [BO](const ConstantRange &CR1, const ConstantRange &CR2) {
+ return CR1.binaryOp(BO->getOpcode(), CR2);
+ });
}
bool LazyValueInfoImpl::solveBlockValueOverflowIntrinsic(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62822.202798.patch
Type: text/x-patch
Size: 2891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190603/8f6ebf7f/attachment.bin>
More information about the llvm-commits
mailing list