Skip to content

Commit 8be07f6

Browse files
committed
InstCombine: Don't use anonymous values in tests
These interfered with opaquification
1 parent 4df6f3f commit 8be07f6

File tree

2 files changed

+81
-75
lines changed

2 files changed

+81
-75
lines changed

llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,68 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
33
target triple = "i386-apple-darwin10.0.0"
44

55
; CHECK-LABEL: define void @fu1(
6-
define void @fu1(i32 %parm) nounwind ssp {
7-
%1 = alloca i32, align 4
8-
; CHECK: alloca double*
6+
define void @fu1(i32 %parm) #0 {
7+
bb:
8+
%i = alloca i32, align 4
9+
10+
; CHECK: alloca double*
911
%ptr = alloca double*, align 4
10-
store i32 %parm, i32* %1, align 4
12+
store i32 %parm, i32* %i, align 4
1113
store double* null, double** %ptr, align 4
12-
%2 = load i32, i32* %1, align 4
13-
%3 = icmp ne i32 %2, 0
14-
br i1 %3, label %4, label %10
14+
%i1 = load i32, i32* %i, align 4
15+
%i2 = icmp ne i32 %i1, 0
16+
br i1 %i2, label %bb3, label %bb9
17+
18+
bb3: ; preds = %bb
19+
%i4 = load i32, i32* %i, align 4
20+
%i5 = shl nuw i32 %i4, 3
21+
; With "nuw", the alloca and its bitcast can be fused:
22+
%i6 = add nuw i32 %i5, 2048
1523

16-
; <label>:4 ; preds = %0
17-
%5 = load i32, i32* %1, align 4
18-
%6 = shl nuw i32 %5, 3
19-
; With "nuw", the alloca and its bitcast can be fused:
20-
%7 = add nuw i32 %6, 2048
21-
; CHECK: alloca double
22-
%8 = alloca i8, i32 %7
23-
%9 = bitcast i8* %8 to double*
24-
; CHECK-NEXT: store double*
25-
store double* %9, double** %ptr, align 4
26-
br label %10
27-
; <label>:10 ; preds = %4, %0
28-
%11 = load double*, double** %ptr, align 4
29-
call void @bar(double* %11)
30-
; CHECK: ret
24+
; CHECK: alloca double
25+
%i7 = alloca i8, i32 %i6, align 1
26+
%i8 = bitcast i8* %i7 to double*
27+
; CHECK-NEXT: store double*
28+
store double* %i8, double** %ptr, align 4
29+
br label %bb9
30+
31+
bb9: ; preds = %bb3, %bb
32+
%i10 = load double*, double** %ptr, align 4
33+
call void @bar(double* %i10)
3134
ret void
3235
}
3336

3437
declare void @bar(double*)
3538

3639
; CHECK-LABEL: define void @fu2(
37-
define void @fu2(i32 %parm) nounwind ssp {
38-
%1 = alloca i32, align 4
40+
define void @fu2(i32 %parm) #0 {
41+
bb:
42+
%i = alloca i32, align 4
3943
%ptr = alloca double*, align 4
40-
store i32 %parm, i32* %1, align 4
44+
store i32 %parm, i32* %i, align 4
4145
store double* null, double** %ptr, align 4
42-
%2 = load i32, i32* %1, align 4
43-
%3 = icmp ne i32 %2, 0
44-
br i1 %3, label %4, label %10
46+
%i1 = load i32, i32* %i, align 4
47+
%i2 = icmp ne i32 %i1, 0
48+
br i1 %i2, label %bb3, label %bb9
49+
50+
bb3: ; preds = %bb
51+
%i4 = load i32, i32* %i, align 4
52+
%i5 = mul nuw i32 %i4, 8
53+
; Without "nuw", the alloca and its bitcast cannot be fused:
54+
%i6 = add i32 %i5, 2048
55+
; CHECK: alloca i8
56+
%i7 = alloca i8, i32 %i6, align 1
4557

46-
; <label>:4 ; preds = %0
47-
%5 = load i32, i32* %1, align 4
48-
%6 = mul nuw i32 %5, 8
49-
; Without "nuw", the alloca and its bitcast cannot be fused:
50-
%7 = add i32 %6, 2048
51-
; CHECK: alloca i8
52-
%8 = alloca i8, i32 %7
53-
; CHECK-NEXT: bitcast double**
54-
; CHECK-NEXT: store i8*
55-
%9 = bitcast i8* %8 to double*
56-
store double* %9, double** %ptr, align 4
57-
br label %10
58+
; CHECK-NEXT: bitcast double**
59+
; CHECK-NEXT: store i8*
60+
%i8 = bitcast i8* %i7 to double*
61+
store double* %i8, double** %ptr, align 4
62+
br label %bb9
5863

59-
; <label>:10 ; preds = %4, %0
60-
%11 = load double*, double** %ptr, align 4
61-
call void @bar(double* %11)
64+
bb9: ; preds = %bb3, %bb
65+
%i10 = load double*, double** %ptr, align 4
66+
call void @bar(double* %i10)
6267
ret void
6368
}
6469

70+
attributes #0 = { nounwind ssp }

llvm/test/Transforms/InstCombine/pr44245.ll

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ define void @test(i1 %c) {
88
; CHECK-NEXT: bb16:
99
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB17:%.*]], label [[BB24:%.*]]
1010
; CHECK: bb17:
11-
; CHECK-NEXT: [[TMP0:%.*]] = phi i8* [ [[TMP1:%.*]], [[BB47:%.*]] ], [ undef, [[BB16:%.*]] ]
12-
; CHECK-NEXT: store i8* [[TMP0]], i8** undef, align 8
11+
; CHECK-NEXT: [[I:%.*]] = phi i8* [ [[TMP0:%.*]], [[BB47:%.*]] ], [ undef, [[BB16:%.*]] ]
12+
; CHECK-NEXT: store i8* [[I]], i8** undef, align 8
1313
; CHECK-NEXT: ret void
1414
; CHECK: bb24:
1515
; CHECK-NEXT: br i1 [[C]], label [[BB44:%.*]], label [[BB49:%.*]]
1616
; CHECK: bb44:
1717
; CHECK-NEXT: [[TMP467:%.*]] = load i8*, i8** inttoptr (i64 16 to i8**), align 16
1818
; CHECK-NEXT: br label [[BB47]]
1919
; CHECK: bb47:
20-
; CHECK-NEXT: [[TMP1]] = phi i8* [ [[TMP2:%.*]], [[BB150:%.*]] ], [ [[TMP1221:%.*]], [[BB119:%.*]] ], [ [[TMP1032:%.*]], [[BB101:%.*]] ], [ [[TMP933:%.*]], [[BB91:%.*]] ], [ [[TMP834:%.*]], [[BB81:%.*]] ], [ [[TMP705:%.*]], [[BB67:%.*]] ], [ [[TMP586:%.*]], [[BB56:%.*]] ], [ [[TMP467]], [[BB44]] ]
20+
; CHECK-NEXT: [[TMP0]] = phi i8* [ [[TMP1:%.*]], [[BB150:%.*]] ], [ [[TMP1221:%.*]], [[BB119:%.*]] ], [ [[TMP1032:%.*]], [[BB101:%.*]] ], [ [[TMP933:%.*]], [[BB91:%.*]] ], [ [[TMP834:%.*]], [[BB81:%.*]] ], [ [[TMP705:%.*]], [[BB67:%.*]] ], [ [[TMP586:%.*]], [[BB56:%.*]] ], [ [[TMP467]], [[BB44]] ]
2121
; CHECK-NEXT: br label [[BB17]]
2222
; CHECK: bb49:
2323
; CHECK-NEXT: br i1 [[C]], label [[BB56]], label [[BB59:%.*]]
@@ -55,95 +55,95 @@ define void @test(i1 %c) {
5555
; CHECK-NEXT: [[TMP1499:%.*]] = load i8*, i8** inttoptr (i64 16 to i8**), align 16
5656
; CHECK-NEXT: br label [[BB150]]
5757
; CHECK: bb150:
58-
; CHECK-NEXT: [[TMP2]] = phi i8* [ [[TMP1848:%.*]], [[BB152]] ], [ [[TMP1499]], [[BB147]] ]
58+
; CHECK-NEXT: [[TMP1]] = phi i8* [ [[TMP1848:%.*]], [[BB152]] ], [ [[TMP1499]], [[BB147]] ]
5959
; CHECK-NEXT: br label [[BB47]]
6060
; CHECK: bb152:
6161
; CHECK-NEXT: [[TMP1848]] = load i8*, i8** inttoptr (i64 16 to i8**), align 16
6262
; CHECK-NEXT: store i1 true, i1* poison, align 1
6363
; CHECK-NEXT: br label [[BB150]]
6464
;
65-
bb16: ; preds = %bb
65+
bb16:
6666
br i1 %c, label %bb17, label %bb24
6767

68-
bb17: ; preds = %bb47, %bb17
69-
%0 = phi i8* [ %1, %bb47 ], [ undef, %bb16 ]
70-
store i8* %0, i8** undef, align 8
68+
bb17: ; preds = %bb47, %bb16
69+
%i = phi i8* [ %i1, %bb47 ], [ undef, %bb16 ]
70+
store i8* %i, i8** undef, align 8
7171
ret void
7272

73-
bb24: ; preds = %bb24
73+
bb24: ; preds = %bb16
7474
br i1 %c, label %bb44, label %bb49
7575

76-
bb44: ; preds = %bb43
76+
bb44: ; preds = %bb24
7777
%tmp46 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
7878
br label %bb47
7979

8080
bb47: ; preds = %bb150, %bb119, %bb101, %bb91, %bb81, %bb67, %bb56, %bb44
8181
%.in1 = phi i64* [ %.in, %bb150 ], [ %tmp122, %bb119 ], [ %tmp103, %bb101 ], [ %tmp93, %bb91 ], [ %tmp83, %bb81 ], [ %tmp70, %bb67 ], [ %tmp58, %bb56 ], [ %tmp46, %bb44 ]
82-
%1 = bitcast i64* %.in1 to i8*
82+
%i1 = bitcast i64* %.in1 to i8*
8383
br label %bb17
8484

85-
bb49: ; preds = %bb49
85+
bb49: ; preds = %bb24
8686
br i1 %c, label %bb56, label %bb59
8787

88-
bb56: ; preds = %bb55
88+
bb56: ; preds = %bb49
8989
%tmp58 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
9090
br label %bb47
9191

92-
bb59: ; preds = %bb59
92+
bb59: ; preds = %bb49
9393
br i1 %c, label %bb67, label %bb71
9494

95-
bb67: ; preds = %bb66
95+
bb67: ; preds = %bb59
9696
%tmp70 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
9797
br label %bb47
9898

99-
bb71: ; preds = %bb71
99+
bb71: ; preds = %bb59
100100
br i1 %c, label %bb81, label %bb84
101101

102-
bb81: ; preds = %bb80
102+
bb81: ; preds = %bb71
103103
%tmp83 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
104104
br label %bb47
105105

106-
bb84: ; preds = %bb84
106+
bb84: ; preds = %bb71
107107
br i1 %c, label %bb91, label %bb94
108108

109-
bb91: ; preds = %bb90
109+
bb91: ; preds = %bb84
110110
%tmp93 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
111111
br label %bb47
112112

113-
bb94: ; preds = %bb94
113+
bb94: ; preds = %bb84
114114
br i1 %c, label %bb101, label %bb104
115115

116-
bb101: ; preds = %bb100
116+
bb101: ; preds = %bb94
117117
%tmp103 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
118118
br label %bb47
119119

120-
bb104: ; preds = %bb104
120+
bb104: ; preds = %bb94
121121
br i1 %c, label %bb119, label %bb123
122122

123-
bb119: ; preds = %bb118
123+
bb119: ; preds = %bb104
124124
%tmp122 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
125125
br label %bb47
126126

127-
bb123: ; preds = %bb123
127+
bb123: ; preds = %bb104
128128
br i1 %c, label %bb147, label %bb152
129129

130-
bb147: ; preds = %bb146
130+
bb147: ; preds = %bb123
131131
%tmp149 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
132132
br label %bb150
133133

134134
bb150: ; preds = %bb152, %bb147
135135
%.in = phi i64* [ %tmp184, %bb152 ], [ %tmp149, %bb147 ]
136136
br label %bb47
137137

138-
bb152: ; preds = %bb146
138+
bb152: ; preds = %bb123
139139
%tmp184 = load i64*, i64** inttoptr (i64 16 to i64**), align 16
140140
call void undef()
141141
br label %bb150
142142
}
143143

144+
144145
; This used to cause an instcombine loop when the problem above was
145146
; addressed in a non-robust fashion.
146-
147147
%type_1 = type {}
148148
%type_2 = type {}
149149
%type_3 = type {}
@@ -177,15 +177,15 @@ while.cond: ; preds = %cond.end144, %entry
177177
for.cond: ; preds = %while.cond
178178
br i1 %c, label %cond.true133, label %cond.false138
179179

180-
cond.true133: ; preds = %sw.epilog
181-
%0 = load %type_2*, %type_2** undef, align 8
180+
cond.true133: ; preds = %for.cond
181+
%i = load %type_2*, %type_2** undef, align 8
182182
br label %cond.end144
183183

184-
cond.false138: ; preds = %sw.epilog
185-
%1 = load %type_2*, %type_2** undef, align 8
184+
cond.false138: ; preds = %for.cond
185+
%i1 = load %type_2*, %type_2** undef, align 8
186186
br label %cond.end144
187187

188188
cond.end144: ; preds = %cond.false138, %cond.true133
189-
%cond145 = phi %type_2* [ %0, %cond.true133 ], [ %1, %cond.false138 ]
189+
%cond145 = phi %type_2* [ %i, %cond.true133 ], [ %i1, %cond.false138 ]
190190
br label %while.cond
191191
}

0 commit comments

Comments
 (0)