Skip to content

Commit 25d9fde

Browse files
author
luxufan
committed
[SCCP] Skip computing intrinsics if one of its args is unknownOrUndef
For constant range supported intrinsics, we got consantrange from args no matter if they are unknown or undef. And the constant range computed from unknown or undef value state is full range. I think compute with full constant range is harmful since although we can do mergeIn after these args value state are changed, the merge operation of two constant ranges is union. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D152499
1 parent 3abdd40 commit 25d9fde

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,8 @@ void SCCPInstVisitor::handleCallResult(CallBase &CB) {
17791779
SmallVector<ConstantRange, 2> OpRanges;
17801780
for (Value *Op : II->args()) {
17811781
const ValueLatticeElement &State = getValueState(Op);
1782+
if (State.isUnknownOrUndef())
1783+
return;
17821784
OpRanges.push_back(getConstantRange(State, Op->getType()));
17831785
}
17841786

llvm/test/Transforms/SCCP/intrinsics.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ define i8 @umax_including_undef(i1 %c.1, i1 %c.2) {
107107
; CHECK: false:
108108
; CHECK-NEXT: br label [[EXIT]]
109109
; CHECK: exit:
110-
; CHECK-NEXT: [[P_UMAX:%.*]] = call i8 @llvm.umax.i8(i8 3, i8 1)
111-
; CHECK-NEXT: ret i8 [[P_UMAX]]
110+
; CHECK-NEXT: ret i8 3
112111
;
113112
br i1 %c.1, label %true, label %false
114113

0 commit comments

Comments
 (0)