1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -enable-new-pm=0 -std-link-opts -S < %s | FileCheck %s
3 ; RUN: opt -passes='lto<O3>' -S < %s | FileCheck %s
5 define void @hoist_fdiv(float* %a, float %b) {
6 ; CHECK-LABEL: @hoist_fdiv(
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 i32 [[I_0]] to i64
15 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A:%.*]], i64 [[IDXPROM]]
16 ; CHECK-NEXT: [[TMP0:%.*]] = load float, float* [[ARRAYIDX]], align 4
17 ; CHECK-NEXT: [[TMP1:%.*]] = fdiv fast float [[TMP0]], [[B:%.*]]
18 ; CHECK-NEXT: store float [[TMP1]], float* [[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, float* %a, i64 %idxprom
38 %0 = load float, float* %arrayidx, align 4
39 %div = fdiv fast float %0, %b
40 store float %div, float* %arrayidx, align 4
44 %inc = add nsw i32 %i.0, 1