1 ; RUN: opt -licm -S < %s | FileCheck %s
2 ; RUN: opt -licm -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
4 ; Function Attrs: noinline norecurse nounwind readnone ssp uwtable
5 define zeroext i1 @invariant_denom(double %v) #0 {
7 ; CHECK-LABEL: @invariant_denom(
9 ; CHECK-NEXT: fdiv fast double 1.000000e+00, %v
12 loop: ; preds = %entry, %loop
13 %v3 = phi i32 [ 0, %entry ], [ %v11, %loop ]
14 %v4 = phi i32 [ 0, %entry ], [ %v12, %loop ]
15 %v5 = uitofp i32 %v4 to double
18 ; CHECK: fmul fast double
20 %v6 = fdiv fast double %v5, %v
21 %v7 = fptoui double %v6 to i64
24 %v10 = trunc i64 %v9 to i32
25 %v11 = add i32 %v10, %v3
26 %v12 = add nuw i32 %v4, 1
27 %v13 = icmp eq i32 %v12, -1
28 br i1 %v13, label %end, label %loop
31 %v15 = phi i32 [ %v11, %loop ]
32 %v16 = icmp ne i32 %v15, 0
36 define void @invariant_fdiv(float* %out, float %arg) {
37 ; CHECK-LABEL: @invariant_fdiv(
39 ; CHECK-NEXT: %div = fdiv fast float 4.000000e+00, %arg
40 ; CHECK-NEXT: fmul fast float %div, 0x41F0000000000000
44 loop: ; preds = %loop, %entry
45 %ind = phi i32 [ 0, %entry ], [ %inc, %loop ]
48 ; CHECK: getelementptr
51 %div = fdiv fast float 4.000000e+00, %arg
52 %mul = fmul fast float %div, 0x41F0000000000000
53 %gep = getelementptr inbounds float, float* %out, i32 %ind
54 store float %mul, float* %gep, align 4
55 %inc = add nuw nsw i32 %ind, 1
56 %cond = icmp eq i32 %inc, 1024
57 br i1 %cond, label %exit, label %loop