1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 define void @test(ptr %a, ptr readnone %a_end, i64 %b, ptr %bf) unnamed_addr {
7 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult ptr [[A:%.*]], [[A_END:%.*]]
8 ; CHECK-NEXT: [[B_FLOAT:%.*]] = inttoptr i64 [[B:%.*]] to ptr
9 ; CHECK-NEXT: br i1 [[CMP1]], label [[BB1:%.*]], label [[BB2:%.*]]
11 ; CHECK-NEXT: [[TMP0:%.*]] = inttoptr i64 [[B]] to ptr
12 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER:%.*]]
14 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER]]
15 ; CHECK: for.body.preheader:
16 ; CHECK-NEXT: [[B_PHI:%.*]] = phi ptr [ [[TMP0]], [[BB1]] ], [ [[BF:%.*]], [[BB2]] ]
17 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
19 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi ptr [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[A]], [[FOR_BODY_PREHEADER]] ]
20 ; CHECK-NEXT: [[B_ADDR_FLOAT:%.*]] = phi ptr [ [[B_ADDR_FLOAT_INC:%.*]], [[FOR_BODY]] ], [ [[B_FLOAT]], [[FOR_BODY_PREHEADER]] ]
21 ; CHECK-NEXT: [[B_ADDR_I64_PTR:%.*]] = phi ptr [ [[B_ADDR_FLOAT_INC]], [[FOR_BODY]] ], [ [[B_PHI]], [[FOR_BODY_PREHEADER]] ]
22 ; CHECK-NEXT: [[L:%.*]] = load float, ptr [[B_ADDR_FLOAT]], align 4
23 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[L]], 4.200000e+01
24 ; CHECK-NEXT: store float [[MUL_I]], ptr [[A_ADDR_03]], align 4
25 ; CHECK-NEXT: [[B_ADDR_FLOAT_INC]] = getelementptr inbounds i8, ptr [[B_ADDR_I64_PTR]], i64 4
26 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i8, ptr [[A_ADDR_03]], i64 4
27 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult ptr [[INCDEC_PTR]], [[A_END]]
28 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
30 ; CHECK-NEXT: ret void
33 %cmp1 = icmp ult ptr %a, %a_end
34 %b.float = inttoptr i64 %b to ptr
35 br i1 %cmp1, label %bb1, label %bb2
38 br label %for.body.preheader
40 %bfi = ptrtoint ptr %bf to i64
41 br label %for.body.preheader
43 for.body.preheader: ; preds = %entry
44 %b.phi = phi i64 [%b, %bb1], [%bfi, %bb2]
47 for.body: ; preds = %for.body.preheader, %for.body
48 %a.addr.03 = phi ptr [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
49 %b.addr.float = phi ptr [ %b.addr.float.inc, %for.body ], [ %b.float, %for.body.preheader ]
50 %b.addr.i64 = phi i64 [ %b.addr.i64.inc, %for.body ], [ %b.phi, %for.body.preheader ]
51 %l = load float, ptr %b.addr.float, align 4
52 %mul.i = fmul float %l, 4.200000e+01
53 store float %mul.i, ptr %a.addr.03, align 4
54 %b.addr.float.2 = inttoptr i64 %b.addr.i64 to ptr
55 %b.addr.float.inc = getelementptr inbounds float, ptr %b.addr.float.2, i64 1
56 %b.addr.i64.inc = ptrtoint ptr %b.addr.float.inc to i64
57 %incdec.ptr = getelementptr inbounds float, ptr %a.addr.03, i64 1
58 %cmp = icmp ult ptr %incdec.ptr, %a_end
59 br i1 %cmp, label %for.body, label %for.end
61 for.end: ; preds = %for.body, %entry