Skip to content

Commit fa63234

Browse files
committed
[InstCombine] Add test for iterator invalidation bug; NFC
1 parent 2a43688 commit fa63234

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -S -instcombine < %s | FileCheck %s
3+
4+
@Q = internal unnamed_addr global double 1.000000e+00, align 8
5+
6+
define double @test(i1 %c, i64* %p) {
7+
; CHECK-LABEL: @test(
8+
; CHECK-NEXT: entry:
9+
; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[END:%.*]]
10+
; CHECK: if:
11+
; CHECK-NEXT: [[LOAD:%.*]] = load i64, i64* bitcast (double* @Q to i64*), align 8
12+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i64 [[LOAD]] to double
13+
; CHECK-NEXT: [[PHITMP:%.*]] = bitcast i64 [[LOAD]] to double
14+
; CHECK-NEXT: br label [[END]]
15+
; CHECK: end:
16+
; CHECK-NEXT: [[TMP1:%.*]] = phi double [ 0.000000e+00, [[ENTRY:%.*]] ], [ [[TMP0]], [[IF]] ]
17+
; CHECK-NEXT: [[PHI:%.*]] = phi double [ 0.000000e+00, [[ENTRY]] ], [ [[PHITMP]], [[IF]] ]
18+
; CHECK-NEXT: [[TMP2:%.*]] = bitcast i64* [[P:%.*]] to double*
19+
; CHECK-NEXT: store double [[TMP1]], double* [[TMP2]], align 8
20+
; CHECK-NEXT: ret double [[PHI]]
21+
;
22+
entry:
23+
br i1 %c, label %if, label %end
24+
25+
if:
26+
%load = load i64, i64* bitcast (double* @Q to i64*), align 8
27+
br label %end
28+
29+
end:
30+
%phi = phi i64 [ 0, %entry ], [ %load, %if ]
31+
store i64 %phi, i64* %p, align 8
32+
%cast = bitcast i64 %phi to double
33+
ret double %cast
34+
35+
uselistorder i64 %phi, { 1, 0 }
36+
}

0 commit comments

Comments
 (0)