+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
declare float @llvm.fma.f32(float, float, float) #1
@external = external global i32
-; CHECK-LABEL: @fma_fneg_x_fneg_y(
-; CHECK: %fma = call float @llvm.fma.f32(float %x, float %y, float %z)
define float @fma_fneg_x_fneg_y(float %x, float %y, float %z) {
+; CHECK-LABEL: @fma_fneg_x_fneg_y(
+; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%x.fneg = fsub float -0.0, %x
%y.fneg = fsub float -0.0, %y
%fma = call float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_fneg_x_fneg_y_fast(
-; CHECK: %fma = call fast float @llvm.fma.f32(float %x, float %y, float %z)
define float @fma_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
+; CHECK-LABEL: @fma_fneg_x_fneg_y_fast(
+; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%x.fneg = fsub float -0.0, %x
%y.fneg = fsub float -0.0, %y
%fma = call fast float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_fneg_const_fneg_y(
-; CHECK: %fma = call float @llvm.fma.f32(float %y, float bitcast (i32 ptrtoint (i32* @external to i32) to float), float %z)
define float @fma_fneg_const_fneg_y(float %y, float %z) {
+; CHECK-LABEL: @fma_fneg_const_fneg_y(
+; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%y.fneg = fsub float -0.0, %y
%fma = call float @llvm.fma.f32(float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_fneg_x_fneg_const(
-; CHECK: %fma = call float @llvm.fma.f32(float %x, float bitcast (i32 ptrtoint (i32* @external to i32) to float), float %z)
define float @fma_fneg_x_fneg_const(float %x, float %z) {
+; CHECK-LABEL: @fma_fneg_x_fneg_const(
+; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%x.fneg = fsub float -0.0, %x
%fma = call float @llvm.fma.f32(float %x.fneg, float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_fabs_x_fabs_y(
-; CHECK: %x.fabs = call float @llvm.fabs.f32(float %x)
-; CHECK: %y.fabs = call float @llvm.fabs.f32(float %y)
-; CHECK: %fma = call float @llvm.fma.f32(float %x.fabs, float %y.fabs, float %z)
define float @fma_fabs_x_fabs_y(float %x, float %y, float %z) {
+; CHECK-LABEL: @fma_fabs_x_fabs_y(
+; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
+; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
+; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X_FABS]], float [[Y_FABS]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%y.fabs = call float @llvm.fabs.f32(float %y)
%fma = call float @llvm.fma.f32(float %x.fabs, float %y.fabs, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_fabs_x_fabs_x(
-; CHECK: %fma = call float @llvm.fma.f32(float %x, float %x, float %z)
define float @fma_fabs_x_fabs_x(float %x, float %z) {
+; CHECK-LABEL: @fma_fabs_x_fabs_x(
+; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%fma = call float @llvm.fma.f32(float %x.fabs, float %x.fabs, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_fabs_x_fabs_x_fast(
-; CHECK: %fma = call fast float @llvm.fma.f32(float %x, float %x, float %z)
define float @fma_fabs_x_fabs_x_fast(float %x, float %z) {
+; CHECK-LABEL: @fma_fabs_x_fabs_x_fast(
+; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%fma = call fast float @llvm.fma.f32(float %x.fabs, float %x.fabs, float %z)
ret float %fma
}
-; CHECK-LABEL: @fmuladd_fneg_x_fneg_y(
-; CHECK: %fmuladd = call float @llvm.fmuladd.f32(float %x, float %y, float %z)
define float @fmuladd_fneg_x_fneg_y(float %x, float %y, float %z) {
+; CHECK-LABEL: @fmuladd_fneg_x_fneg_y(
+; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%x.fneg = fsub float -0.0, %x
%y.fneg = fsub float -0.0, %y
%fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fmuladd_fneg_x_fneg_y_fast(
-; CHECK-NEXT: %1 = fmul fast float %x, %y
-; CHECK-NEXT: %fmuladd = fadd fast float %1, %z
define float @fmuladd_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
+; CHECK-LABEL: @fmuladd_fneg_x_fneg_y_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%x.fneg = fsub float -0.0, %x
%y.fneg = fsub float -0.0, %y
%fmuladd = call fast float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fmuladd_fneg_const_fneg_y(
-; CHECK: %fmuladd = call float @llvm.fmuladd.f32(float %y, float bitcast (i32 ptrtoint (i32* @external to i32) to float), float %z)
define float @fmuladd_fneg_const_fneg_y(float %y, float %z) {
+; CHECK-LABEL: @fmuladd_fneg_const_fneg_y(
+; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%y.fneg = fsub float -0.0, %y
%fmuladd = call float @llvm.fmuladd.f32(float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fmuladd_fneg_x_fneg_const(
-; CHECK: %fmuladd = call float @llvm.fmuladd.f32(float %x, float bitcast (i32 ptrtoint (i32* @external to i32) to float), float %z)
define float @fmuladd_fneg_x_fneg_const(float %x, float %z) {
+; CHECK-LABEL: @fmuladd_fneg_x_fneg_const(
+; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%x.fneg = fsub float -0.0, %x
%fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fmuladd_fabs_x_fabs_y(
-; CHECK: %x.fabs = call float @llvm.fabs.f32(float %x)
-; CHECK: %y.fabs = call float @llvm.fabs.f32(float %y)
-; CHECK: %fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %y.fabs, float %z)
define float @fmuladd_fabs_x_fabs_y(float %x, float %y, float %z) {
+; CHECK-LABEL: @fmuladd_fabs_x_fabs_y(
+; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
+; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
+; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X_FABS]], float [[Y_FABS]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%y.fabs = call float @llvm.fabs.f32(float %y)
%fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %y.fabs, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fmuladd_fabs_x_fabs_x(
-; CHECK: %fmuladd = call float @llvm.fmuladd.f32(float %x, float %x, float %z)
define float @fmuladd_fabs_x_fabs_x(float %x, float %z) {
+; CHECK-LABEL: @fmuladd_fabs_x_fabs_x(
+; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fmuladd_fabs_x_fabs_x_fast(
-; CHECK-NEXT: %1 = fmul fast float %x, %x
-; CHECK-NEXT: %fmuladd = fadd fast float %1, %z
define float @fmuladd_fabs_x_fabs_x_fast(float %x, float %z) {
+; CHECK-LABEL: @fmuladd_fabs_x_fabs_x_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[X]]
+; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%fmuladd = call fast float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fma_k_y_z(
-; CHECK: %fma = call float @llvm.fma.f32(float %y, float 4.000000e+00, float %z)
define float @fma_k_y_z(float %y, float %z) {
+; CHECK-LABEL: @fma_k_y_z(
+; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%fma = call float @llvm.fma.f32(float 4.0, float %y, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_k_y_z_fast(
-; CHECK: %fma = call fast float @llvm.fma.f32(float %y, float 4.000000e+00, float %z)
define float @fma_k_y_z_fast(float %y, float %z) {
+; CHECK-LABEL: @fma_k_y_z_fast(
+; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
+; CHECK-NEXT: ret float [[FMA]]
+;
%fma = call fast float @llvm.fma.f32(float 4.0, float %y, float %z)
ret float %fma
}
-; CHECK-LABEL: @fmuladd_k_y_z_fast(
-; CHECK: %1 = fmul fast float %y, 4.000000e+00
-; CHECK-NEXT: %fmuladd = fadd fast float %1, %z
define float @fmuladd_k_y_z_fast(float %y, float %z) {
+; CHECK-LABEL: @fmuladd_k_y_z_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[Y:%.*]], 4.000000e+00
+; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%fmuladd = call fast float @llvm.fmuladd.f32(float 4.0, float %y, float %z)
ret float %fmuladd
}
-; CHECK-LABEL: @fma_1_y_z(
-; CHECK: %fma = fadd float %y, %z
define float @fma_1_y_z(float %y, float %z) {
+; CHECK-LABEL: @fma_1_y_z(
+; CHECK-NEXT: [[FMA:%.*]] = fadd float [[Y:%.*]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMA]]
+;
%fma = call float @llvm.fma.f32(float 1.0, float %y, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_x_1_z(
-; CHECK: %fma = fadd float %x, %z
define float @fma_x_1_z(float %x, float %z) {
+; CHECK-LABEL: @fma_x_1_z(
+; CHECK-NEXT: [[FMA:%.*]] = fadd float [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMA]]
+;
%fma = call float @llvm.fma.f32(float %x, float 1.0, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_x_1_z_v2f32(
-; CHECK: %fma = fadd <2 x float> %x, %z
define <2 x float> @fma_x_1_z_v2f32(<2 x float> %x, <2 x float> %z) {
+; CHECK-LABEL: @fma_x_1_z_v2f32(
+; CHECK-NEXT: [[FMA:%.*]] = fadd <2 x float> [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: ret <2 x float> [[FMA]]
+;
%fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %x, <2 x float> <float 1.0, float 1.0>, <2 x float> %z)
ret <2 x float> %fma
}
-; CHECK-LABEL: @fma_x_1_2_z_v2f32(
-; CHECK: %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %x, <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> %z)
define <2 x float> @fma_x_1_2_z_v2f32(<2 x float> %x, <2 x float> %z) {
+; CHECK-LABEL: @fma_x_1_2_z_v2f32(
+; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> [[Z:%.*]])
+; CHECK-NEXT: ret <2 x float> [[FMA]]
+;
%fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %x, <2 x float> <float 1.0, float 2.0>, <2 x float> %z)
ret <2 x float> %fma
}
-; CHECK-LABEL: @fma_x_1_z_fast(
-; CHECK: %fma = fadd fast float %x, %z
define float @fma_x_1_z_fast(float %x, float %z) {
+; CHECK-LABEL: @fma_x_1_z_fast(
+; CHECK-NEXT: [[FMA:%.*]] = fadd fast float [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMA]]
+;
%fma = call fast float @llvm.fma.f32(float %x, float 1.0, float %z)
ret float %fma
}
-; CHECK-LABEL: @fma_1_1_z(
-; CHECK: %fma = fadd float %z, 1.0
define float @fma_1_1_z(float %z) {
+; CHECK-LABEL: @fma_1_1_z(
+; CHECK-NEXT: [[FMA:%.*]] = fadd float [[Z:%.*]], 1.000000e+00
+; CHECK-NEXT: ret float [[FMA]]
+;
%fma = call float @llvm.fma.f32(float 1.0, float 1.0, float %z)
ret float %fma
}
-; CHECK-LABEL: @fmuladd_x_1_z_fast(
-; CHECK: %fmuladd = fadd fast float %x, %z
define float @fmuladd_x_1_z_fast(float %x, float %z) {
+; CHECK-LABEL: @fmuladd_x_1_z_fast(
+; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[FMULADD]]
+;
%fmuladd = call fast float @llvm.fmuladd.f32(float %x, float 1.0, float %z)
ret float %fmuladd
}
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
; (-0.0 - X) * C => X * -C
define float @test1(float %x) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X:%.*]], -2.000000e+01
+; CHECK-NEXT: ret float [[MUL]]
+;
%sub = fsub float -0.000000e+00, %x
%mul = fmul float %sub, 2.0e+1
ret float %mul
-
-; CHECK-LABEL: @test1(
-; CHECK: fmul float %x, -2.000000e+01
}
; (0.0 - X) * C => X * -C
define float @test2(float %x) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X:%.*]], -2.000000e+01
+; CHECK-NEXT: ret float [[MUL]]
+;
%sub = fsub nsz float 0.000000e+00, %x
%mul = fmul float %sub, 2.0e+1
ret float %mul
-
-; CHECK-LABEL: @test2(
-; CHECK: fmul float %x, -2.000000e+01
}
; (-0.0 - X) * (-0.0 - Y) => X * Y
define float @test3(float %x, float %y) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: [[MUL:%.*]] = fmul fast float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%sub1 = fsub float -0.000000e+00, %x
%sub2 = fsub float -0.000000e+00, %y
%mul = fmul fast float %sub1, %sub2
ret float %mul
-; CHECK-LABEL: @test3(
-; CHECK: fmul fast float %x, %y
}
; (0.0 - X) * (0.0 - Y) => X * Y
define float @test4(float %x, float %y) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%sub1 = fsub nsz float 0.000000e+00, %x
%sub2 = fsub nsz float 0.000000e+00, %y
%mul = fmul float %sub1, %sub2
ret float %mul
-; CHECK-LABEL: @test4(
-; CHECK: fmul float %x, %y
}
; (-0.0 - X) * Y => -0.0 - (X * Y)
define float @test5(float %x, float %y) {
+; CHECK-LABEL: @test5(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = fsub float -0.000000e+00, [[TMP1]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%sub1 = fsub float -0.000000e+00, %x
%mul = fmul float %sub1, %y
ret float %mul
-; CHECK-LABEL: @test5(
-; CHECK: %1 = fmul float %x, %y
-; CHECK: %mul = fsub float -0.000000e+00, %1
}
; (0.0 - X) * Y => 0.0 - (X * Y)
define float @test6(float %x, float %y) {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = fsub float -0.000000e+00, [[TMP1]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%sub1 = fsub nsz float 0.000000e+00, %x
%mul = fmul float %sub1, %y
ret float %mul
-; CHECK-LABEL: @test6(
-; CHECK: %1 = fmul float %x, %y
-; CHECK: %mul = fsub float -0.000000e+00, %1
}
; "(-0.0 - X) * Y => -0.0 - (X * Y)" is disabled if expression "-0.0 - X"
; has multiple uses.
define float @test7(float %x, float %y) {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT: [[SUB1:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[SUB1]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL2:%.*]] = fmul float [[MUL]], [[SUB1]]
+; CHECK-NEXT: ret float [[MUL2]]
+;
%sub1 = fsub float -0.000000e+00, %x
%mul = fmul float %sub1, %y
%mul2 = fmul float %mul, %sub1
ret float %mul2
-; CHECK-LABEL: @test7(
-; CHECK: fsub float -0.000000e+00, %x
}
; Don't crash when attempting to cast a constant FMul to an instruction.
define void @test8(i32* %inout) {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_COND:%.*]]
+; CHECK: for.cond:
+; CHECK-NEXT: [[LOCAL_VAR_7_0:%.*]] = phi <4 x float> [ <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, [[ENTRY:%.*]] ], [ [[TMP0:%.*]], [[FOR_BODY:%.*]] ]
+; CHECK-NEXT: br i1 undef, label [[FOR_BODY]], label [[FOR_END:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[TMP0]] = insertelement <4 x float> [[LOCAL_VAR_7_0]], float 0.000000e+00, i32 2
+; CHECK-NEXT: br label [[FOR_COND]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
entry:
%0 = load i32, i32* %inout, align 4
%conv = uitofp i32 %0 to float
; X * -1.0 => -0.0 - X
define float @test9(float %x) {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT: [[MUL:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%mul = fmul float %x, -1.0
ret float %mul
-
-; CHECK-LABEL: @test9(
-; CHECK-NOT: fmul
-; CHECK: fsub
}
; PR18532
define <4 x float> @test10(<4 x float> %x) {
+; CHECK-LABEL: @test10(
+; CHECK-NEXT: [[MUL:%.*]] = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
+; CHECK-NEXT: ret <4 x float> [[MUL]]
+;
%mul = fmul <4 x float> %x, <float -1.0, float -1.0, float -1.0, float -1.0>
ret <4 x float> %mul
-
-; CHECK-LABEL: @test10(
-; CHECK-NOT: fmul
-; CHECK: fsub
}
define float @test11(float %x, float %y) {
+; CHECK-LABEL: @test11(
+; CHECK-NEXT: [[B:%.*]] = fadd fast float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[C:%.*]] = fadd fast float [[B]], 3.000000e+00
+; CHECK-NEXT: ret float [[C]]
+;
%a = fadd fast float %x, 1.0
%b = fadd fast float %y, 2.0
%c = fadd fast float %a, %b
ret float %c
-; CHECK-LABEL: @test11(
-; CHECK-NOT: fadd float
-; CHECK: fadd fast float
}
; PR21126: http://llvm.org/bugs/show_bug.cgi?id=21126
declare double @llvm.sqrt.f64(double)
define double @sqrt_squared1(double %f) {
+; CHECK-LABEL: @sqrt_squared1(
+; CHECK-NEXT: ret double [[F:%.*]]
+;
%sqrt = call double @llvm.sqrt.f64(double %f)
%mul = fmul fast double %sqrt, %sqrt
ret double %mul
-; CHECK-LABEL: @sqrt_squared1(
-; CHECK-NEXT: ret double %f
}
-; With unsafe/fast math, sqrt(X) * sqrt(X) is just X,
+; With unsafe/fast math, sqrt(X) * sqrt(X) is just X,
; but make sure another use of the sqrt is intact.
; Note that the remaining fmul is altered but is not 'fast'
-; itself because it was not marked 'fast' originally.
+; itself because it was not marked 'fast' originally.
; Thus, we have an overall fast result, but no more indication of
; 'fast'ness in the code.
define double @sqrt_squared2(double %f) {
+; CHECK-LABEL: @sqrt_squared2(
+; CHECK-NEXT: [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[F:%.*]])
+; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[SQRT]], [[F]]
+; CHECK-NEXT: ret double [[MUL2]]
+;
%sqrt = call double @llvm.sqrt.f64(double %f)
%mul1 = fmul fast double %sqrt, %sqrt
%mul2 = fmul double %mul1, %sqrt
ret double %mul2
-; CHECK-LABEL: @sqrt_squared2(
-; CHECK-NEXT: %sqrt = call double @llvm.sqrt.f64(double %f)
-; CHECK-NEXT: %mul2 = fmul double %sqrt, %f
-; CHECK-NEXT: ret double %mul2
}
declare float @llvm.fabs.f32(float) nounwind readnone
-; CHECK-LABEL @fabs_squared(
-; CHECK: %mul = fmul float %x, %x
define float @fabs_squared(float %x) {
+; CHECK-LABEL: @fabs_squared(
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X:%.*]], [[X]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%mul = fmul float %x.fabs, %x.fabs
ret float %mul
}
-; CHECK-LABEL @fabs_squared_fast(
-; CHECK: %mul = fmul fast float %x, %x
define float @fabs_squared_fast(float %x) {
+; CHECK-LABEL: @fabs_squared_fast(
+; CHECK-NEXT: [[MUL:%.*]] = fmul fast float [[X:%.*]], [[X]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%mul = fmul fast float %x.fabs, %x.fabs
ret float %mul
}
-; CHECK-LABEL @fabs_x_fabs(
-; CHECK: call float @llvm.fabs.f32(float %x)
-; CHECK: call float @llvm.fabs.f32(float %y)
-; CHECK: %mul = fmul float %x.fabs, %y.fabs
define float @fabs_x_fabs(float %x, float %y) {
+; CHECK-LABEL: @fabs_x_fabs(
+; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
+; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X_FABS]], [[Y_FABS]]
+; CHECK-NEXT: ret float [[MUL]]
+;
%x.fabs = call float @llvm.fabs.f32(float %x)
%y.fabs = call float @llvm.fabs.f32(float %y)
%mul = fmul float %x.fabs, %y.fabs