Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/SCCPSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU,
static void inferAttribute(Function *F, unsigned AttrIndex,
const ValueLatticeElement &Val) {
// If there is a known constant range for the value, add range attribute.
if (Val.isConstantRange() && !Val.getConstantRange().isSingleElement()) {
if (Val.isConstantRange()) {
// Do not add range attribute if the value may include undef.
if (Val.isConstantRangeIncludingUndef())
return;
Expand Down
46 changes: 46 additions & 0 deletions llvm/test/Transforms/SCCP/post-update-unknown.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=sccp < %s | FileCheck %s --check-prefixes=CHECK,SCCP
; RUN: opt -S -passes=ipsccp < %s | FileCheck %s --check-prefixes=CHECK,IPSCCP

; Test the case when a \bot (unknown) in lattice is updated to a constrange
; via updates of non-operand

define i32 @bar() {
; CHECK-LABEL: define range(i32 1, -2147483648) i32 @bar() {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[V1:%.*]] = call i32 (...) @pred()
; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[V1]], 0
; CHECK-NEXT: br i1 [[DOTNOT]], label %[[EXIT:.*]], label %[[BR1:.*]]
; CHECK: [[BR1]]:
; CHECK-NEXT: [[V3:%.*]] = call i32 @bar()
; CHECK-NEXT: [[V4:%.*]] = icmp sgt i32 [[V3]], 1
; CHECK-NEXT: br i1 [[V4]], label %[[EXIT]], label %[[BR2:.*]]
; CHECK: [[BR2]]:
; CHECK-NEXT: br label %[[EXIT]]
; CHECK: [[EXIT]]:
; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ [[V3]], %[[BR1]] ], [ 2, %[[BR2]] ], [ 1, %[[ENTRY]] ]
; CHECK-NEXT: ret i32 [[DOT0]]
;
entry:
%v1 = call i32 (...) @pred()
%.not = icmp eq i32 %v1, 0
br i1 %.not, label %exit, label %br1

br1: ; preds = %entry
%v3 = call i32 @bar()
%v4 = icmp sgt i32 %v3, 1
br i1 %v4, label %exit, label %br2

br2: ; preds = %br1
br label %exit

exit: ; preds = %br2, %br1, %entry
%.0 = phi i32 [ %v3, %br1 ], [ 2, %br2 ], [ 1, %entry ]
ret i32 %.0
}

declare i32 @pred(...)

;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; IPSCCP: {{.*}}
; SCCP: {{.*}}
Loading