Skip to content

Commit 03e0be9

Browse files
committed
[SCCP] Make use of argument attributes in non-ip SCCP
Initialize arguments based on attributes instead of hardcoding them to overdefined. This was already properly done for ipsccp.
1 parent 1e5f336 commit 03e0be9

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

llvm/lib/Transforms/Scalar/SCCP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ static bool runSCCP(Function &F, const DataLayout &DL,
6969
// Mark the first block of the function as being executable.
7070
Solver.markBlockExecutable(&F.front());
7171

72-
// Mark all arguments to the function as being overdefined.
72+
// Initialize arguments based on attributes.
7373
for (Argument &AI : F.args())
74-
Solver.markOverdefined(&AI);
74+
Solver.trackValueOfArgument(&AI);
7575

7676
// Solve for constants.
7777
bool ResolvedUndefs = true;

llvm/test/Transforms/SCCP/range-attribute.ll

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,14 @@ declare void @use(i1)
66
declare i32 @get_i32()
77

88
define void @range_attribute(i32 range(i32 0, 10) %v) {
9-
; IPSCCP-LABEL: @range_attribute(
10-
; IPSCCP-NEXT: call void @use(i1 true)
11-
; IPSCCP-NEXT: [[C2:%.*]] = icmp ult i32 [[V:%.*]], 9
12-
; IPSCCP-NEXT: call void @use(i1 [[C2]])
13-
; IPSCCP-NEXT: call void @use(i1 false)
14-
; IPSCCP-NEXT: [[C4:%.*]] = icmp ugt i32 [[V]], 8
15-
; IPSCCP-NEXT: call void @use(i1 [[C4]])
16-
; IPSCCP-NEXT: ret void
17-
;
18-
; SCCP-LABEL: @range_attribute(
19-
; SCCP-NEXT: [[C1:%.*]] = icmp ult i32 [[V:%.*]], 10
20-
; SCCP-NEXT: call void @use(i1 [[C1]])
21-
; SCCP-NEXT: [[C2:%.*]] = icmp ult i32 [[V]], 9
22-
; SCCP-NEXT: call void @use(i1 [[C2]])
23-
; SCCP-NEXT: [[C3:%.*]] = icmp ugt i32 [[V]], 9
24-
; SCCP-NEXT: call void @use(i1 [[C3]])
25-
; SCCP-NEXT: [[C4:%.*]] = icmp ugt i32 [[V]], 8
26-
; SCCP-NEXT: call void @use(i1 [[C4]])
27-
; SCCP-NEXT: ret void
9+
; CHECK-LABEL: @range_attribute(
10+
; CHECK-NEXT: call void @use(i1 true)
11+
; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[V:%.*]], 9
12+
; CHECK-NEXT: call void @use(i1 [[C2]])
13+
; CHECK-NEXT: call void @use(i1 false)
14+
; CHECK-NEXT: [[C4:%.*]] = icmp ugt i32 [[V]], 8
15+
; CHECK-NEXT: call void @use(i1 [[C4]])
16+
; CHECK-NEXT: ret void
2817
;
2918
%c1 = icmp ult i32 %v, 10
3019
call void @use(i1 %c1)

0 commit comments

Comments
 (0)