1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='lto<O3>' -S < %s | FileCheck %s
4 define void @hoist_fdiv(ptr %a, float %b) {
5 ; CHECK-LABEL: @hoist_fdiv(
7 ; CHECK-NEXT: [[TMP0:%.*]] = fdiv fast float 1.000000e+00, [[B:%.*]]
8 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
10 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
11 ; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq i32 [[I_0]], 1024
12 ; CHECK-NEXT: br i1 [[CMP_NOT]], label [[FOR_END:%.*]], label [[FOR_INC]]
14 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext nneg i32 [[I_0]] to i64
15 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[A:%.*]], i64 [[IDXPROM]]
16 ; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr [[ARRAYIDX]], align 4
17 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[TMP0]]
18 ; CHECK-NEXT: store float [[TMP2]], ptr [[ARRAYIDX]], align 4
19 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_0]], 1
20 ; CHECK-NEXT: br label [[FOR_COND]]
22 ; CHECK-NEXT: ret void
28 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
29 %cmp = icmp ne i32 %i.0, 1024
30 br i1 %cmp, label %for.body, label %for.cond.cleanup
36 %idxprom = sext i32 %i.0 to i64
37 %arrayidx = getelementptr inbounds float, ptr %a, i64 %idxprom
38 %0 = load float, ptr %arrayidx, align 4
39 %div = fdiv fast float %0, %b
40 store float %div, ptr %arrayidx, align 4
44 %inc = add nsw i32 %i.0, 1