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(float* %a, float %b) {
5 ; CHECK-LABEL: @hoist_fdiv(
7 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
9 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
10 ; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq i32 [[I_0]], 1024
11 ; CHECK-NEXT: br i1 [[CMP_NOT]], label [[FOR_END:%.*]], label [[FOR_INC]]
13 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_0]] to i64
14 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A:%.*]], i64 [[IDXPROM]]
15 ; CHECK-NEXT: [[TMP0:%.*]] = load float, float* [[ARRAYIDX]], align 4
16 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv fast float [[TMP0]], [[B:%.*]]
17 ; CHECK-NEXT: store float [[TMP1]], float* [[ARRAYIDX]], align 4
18 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_0]], 1
19 ; CHECK-NEXT: br label [[FOR_COND]]
21 ; CHECK-NEXT: ret void
27 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
28 %cmp = icmp ne i32 %i.0, 1024
29 br i1 %cmp, label %for.body, label %for.cond.cleanup
35 %idxprom = sext i32 %i.0 to i64
36 %arrayidx = getelementptr inbounds float, float* %a, i64 %idxprom
37 %0 = load float, float* %arrayidx, align 4
38 %div = fdiv fast float %0, %b
39 store float %div, float* %arrayidx, align 4
43 %inc = add nsw i32 %i.0, 1