1; RUN: opt -licm -S < %s | FileCheck %s 2; RUN: opt -licm -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s 3 4; Function Attrs: noinline norecurse nounwind readnone ssp uwtable 5define zeroext i1 @invariant_denom(double %v) #0 { 6entry: 7; CHECK-LABEL: @invariant_denom( 8; CHECK-NEXT: entry: 9; CHECK-NEXT: fdiv fast double 1.000000e+00, %v 10 br label %loop 11 12loop: ; 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 16 17; CHECK-LABEL: loop: 18; CHECK: fmul fast double 19; CHECK-NOT: fdiv 20 %v6 = fdiv fast double %v5, %v 21 %v7 = fptoui double %v6 to i64 22 %v8 = and i64 %v7, 1 23 %v9 = xor i64 %v8, 1 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 29 30end: ; preds = %loop 31 %v15 = phi i32 [ %v11, %loop ] 32 %v16 = icmp ne i32 %v15, 0 33 ret i1 %v16 34} 35 36define void @invariant_fdiv(float* %out, float %arg) { 37; CHECK-LABEL: @invariant_fdiv( 38; CHECK-NEXT: entry: 39; CHECK-NEXT: %div = fdiv fast float 4.000000e+00, %arg 40; CHECK-NEXT: fmul fast float %div, 0x41F0000000000000 41entry: 42 br label %loop 43 44loop: ; preds = %loop, %entry 45 %ind = phi i32 [ 0, %entry ], [ %inc, %loop ] 46 47; CHECK-LABEL: loop: 48; CHECK: getelementptr 49; CHECK-NOT: fdiv 50; CHECK-NOT: fmul 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 58 59exit: ; preds = %loop 60 ret void 61} 62