1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 define void @matching_phi(i64 %a, ptr %b, i1 %cond) {
5 ; CHECK-LABEL: @matching_phi(
7 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[BB2:%.*]], label [[BB1:%.*]]
9 ; CHECK-NEXT: [[ADDB:%.*]] = getelementptr inbounds i8, ptr [[B:%.*]], i64 8
10 ; CHECK-NEXT: br label [[BB3:%.*]]
12 ; CHECK-NEXT: [[ADD_INT:%.*]] = add i64 [[A:%.*]], 1
13 ; CHECK-NEXT: [[ADD:%.*]] = inttoptr i64 [[ADD_INT]] to ptr
14 ; CHECK-NEXT: store float 1.000000e+01, ptr [[ADD]], align 4
15 ; CHECK-NEXT: br label [[BB3]]
17 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi ptr [ [[ADDB]], [[BB1]] ], [ [[ADD]], [[BB2]] ]
18 ; CHECK-NEXT: [[I1:%.*]] = load float, ptr [[A_ADDR_03]], align 4
19 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
20 ; CHECK-NEXT: store float [[MUL_I]], ptr [[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 ptr
28 %addb = getelementptr inbounds float, ptr %b, i64 2
29 %addb.int = ptrtoint ptr %addb to i64
30 br i1 %cmp1, label %bb1, label %bb2
34 store float 1.0e+01, ptr %add, align 4
38 %a.addr.03 = phi ptr [ %addb, %bb1 ], [ %add, %bb2 ]
39 %b.addr.02 = phi i64 [ %addb.int, %bb1 ], [ %add.int, %bb2 ]
40 %i0 = inttoptr i64 %b.addr.02 to ptr
41 %i1 = load float, ptr %i0, align 4
42 %mul.i = fmul float %i1, 4.200000e+01
43 store float %mul.i, ptr %a.addr.03, align 4
47 define void @no_matching_phi(i64 %a, ptr %b, i1 %cond) {
48 ; CHECK-LABEL: @no_matching_phi(
50 ; CHECK-NEXT: [[ADD_INT:%.*]] = add i64 [[A:%.*]], 1
51 ; CHECK-NEXT: [[ADDB:%.*]] = getelementptr inbounds i8, ptr [[B:%.*]], i64 8
52 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[B:%.*]], label [[A:%.*]]
54 ; CHECK-NEXT: [[TMP0:%.*]] = inttoptr i64 [[ADD_INT]] to ptr
55 ; CHECK-NEXT: br label [[C:%.*]]
57 ; CHECK-NEXT: [[ADD:%.*]] = inttoptr i64 [[ADD_INT]] to ptr
58 ; CHECK-NEXT: store float 1.000000e+01, ptr [[ADD]], align 4
59 ; CHECK-NEXT: br label [[C]]
61 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi ptr [ [[ADDB]], [[A]] ], [ [[ADD]], [[B]] ]
62 ; CHECK-NEXT: [[B_ADDR_02:%.*]] = phi ptr [ [[TMP0]], [[A]] ], [ [[ADDB]], [[B]] ]
63 ; CHECK-NEXT: [[I1:%.*]] = load float, ptr [[B_ADDR_02]], align 4
64 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
65 ; CHECK-NEXT: store float [[MUL_I]], ptr [[A_ADDR_03]], align 4
66 ; CHECK-NEXT: ret void
69 %cmp1 = icmp eq i1 %cond, 0
70 %add.int = add i64 %a, 1
71 %add = inttoptr i64 %add.int to ptr
73 %addb = getelementptr inbounds float, ptr %b, i64 2
74 %addb.int = ptrtoint ptr %addb to i64
75 br i1 %cmp1, label %A, label %B
79 store float 1.0e+01, ptr %add, align 4
83 %a.addr.03 = phi ptr [ %addb, %A ], [ %add, %B ]
84 %b.addr.02 = phi i64 [ %addb.int, %B ], [ %add.int, %A ]
85 %i0 = inttoptr i64 %b.addr.02 to ptr
86 %i1 = load float, ptr %i0, align 4
87 %mul.i = fmul float %i1, 4.200000e+01
88 store float %mul.i, ptr %a.addr.03, align 4