1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define void @matching_phi(i64 %a, float* %b, i1 %cond) {
5 ; CHECK-LABEL: @matching_phi(
7 ; CHECK-NEXT: [[ADD_INT:%.*]] = add i64 [[A:%.*]], 1
8 ; CHECK-NEXT: [[ADD:%.*]] = inttoptr i64 [[ADD_INT]] to float*
9 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[BBB:%.*]], label [[A:%.*]]
11 ; CHECK-NEXT: [[ADDB:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 2
12 ; CHECK-NEXT: br label [[C:%.*]]
14 ; CHECK-NEXT: store float 1.000000e+01, float* [[ADD]], align 4
15 ; CHECK-NEXT: br label [[C]]
17 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[ADDB]], [[A]] ], [ [[ADD]], [[BBB]] ]
18 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[A_ADDR_03]], align 4
19 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
20 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
21 ; CHECK-NEXT: ret void
24 %cmp1 = icmp eq i1 %cond, 0
25 %add.int = add i64 %a, 1
26 %add = inttoptr i64 %add.int to float *
28 %addb = getelementptr inbounds float, float* %b, i64 2
29 %addb.int = ptrtoint float* %addb to i64
30 br i1 %cmp1, label %A, label %Bbb
34 store float 1.0e+01, float* %add, align 4
38 %a.addr.03 = phi float* [ %addb, %A ], [ %add, %Bbb ]
39 %b.addr.02 = phi i64 [ %addb.int, %A ], [ %add.int, %Bbb ]
40 %i0 = inttoptr i64 %b.addr.02 to float*
41 %i1 = load float, float* %i0, align 4
42 %mul.i = fmul float %i1, 4.200000e+01
43 store float %mul.i, float* %a.addr.03, align 4
47 define void @no_matching_phi(i64 %a, float* %b, i1 %cond) {
48 ; CHECK-LABEL: @no_matching_phi(
50 ; CHECK-NEXT: [[ADD_INT:%.*]] = add i64 [[A:%.*]], 1
51 ; CHECK-NEXT: [[ADD:%.*]] = inttoptr i64 [[ADD_INT]] to float*
52 ; CHECK-NEXT: [[ADDB:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 2
53 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[B:%.*]], label [[A:%.*]]
55 ; CHECK-NEXT: br label [[C:%.*]]
57 ; CHECK-NEXT: store float 1.000000e+01, float* [[ADD]], align 4
58 ; CHECK-NEXT: br label [[C]]
60 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[ADDB]], [[A]] ], [ [[ADD]], [[B]] ]
61 ; CHECK-NEXT: [[B_ADDR_02_PTR:%.*]] = phi float* [ [[ADD]], [[A]] ], [ [[ADDB]], [[B]] ]
62 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
63 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
64 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
65 ; CHECK-NEXT: ret void
68 %cmp1 = icmp eq i1 %cond, 0
69 %add.int = add i64 %a, 1
70 %add = inttoptr i64 %add.int to float *
72 %addb = getelementptr inbounds float, float* %b, i64 2
73 %addb.int = ptrtoint float* %addb to i64
74 br i1 %cmp1, label %A, label %B
78 store float 1.0e+01, float* %add, align 4
82 %a.addr.03 = phi float* [ %addb, %A ], [ %add, %B ]
83 %b.addr.02 = phi i64 [ %addb.int, %B ], [ %add.int, %A ]
84 %i0 = inttoptr i64 %b.addr.02 to float*
85 %i1 = load float, float* %i0, align 4
86 %mul.i = fmul float %i1, 4.200000e+01
87 store float %mul.i, float* %a.addr.03, align 4