From 8f390d939972d66eec1d55070d3c6bccd0ac581f Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Fri, 31 May 2019 14:49:31 +0000 Subject: [PATCH] [NFC][InstCombine] Add unary FNeg tests to fma.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362227 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/fma.ll | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/test/Transforms/InstCombine/fma.ll b/test/Transforms/InstCombine/fma.ll index 7bb6619b4fd..f3314c622bc 100644 --- a/test/Transforms/InstCombine/fma.ll +++ b/test/Transforms/InstCombine/fma.ll @@ -19,6 +19,17 @@ define float @fma_fneg_x_fneg_y(float %x, float %y, float %z) { ret float %fma } +define float @fma_unary_fneg_x_unary_fneg_y(float %x, float %y, float %z) { +; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y( +; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) +; CHECK-NEXT: ret float [[FMA]] +; + %x.fneg = fneg float %x + %y.fneg = fneg float %y + %fma = call float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z) + ret float %fma +} + define <2 x float> @fma_fneg_x_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x float> %z) { ; CHECK-LABEL: @fma_fneg_x_fneg_y_vec( ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]]) @@ -30,6 +41,17 @@ define <2 x float> @fma_fneg_x_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x f ret <2 x float> %fma } +define <2 x float> @fma_unary_fneg_x_unary_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x float> %z) { +; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y_vec( +; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]]) +; CHECK-NEXT: ret <2 x float> [[FMA]] +; + %xn = fneg <2 x float> %x + %yn = fneg <2 x float> %y + %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z) + ret <2 x float> %fma +} + define <2 x float> @fma_fneg_x_fneg_y_vec_undef(<2 x float> %x, <2 x float> %y, <2 x float> %z) { ; CHECK-LABEL: @fma_fneg_x_fneg_y_vec_undef( ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]]) @@ -52,6 +74,17 @@ define float @fma_fneg_x_fneg_y_fast(float %x, float %y, float %z) { ret float %fma } +define float @fma_unary_fneg_x_unary_fneg_y_fast(float %x, float %y, float %z) { +; CHECK-LABEL: @fma_unary_fneg_x_unary_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 = fneg float %x + %y.fneg = fneg float %y + %fma = call fast float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z) + ret float %fma +} + 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:%.*]]) @@ -62,6 +95,16 @@ define float @fma_fneg_const_fneg_y(float %y, float %z) { ret float %fma } +define float @fma_unary_fneg_const_unary_fneg_y(float %y, float %z) { +; CHECK-LABEL: @fma_unary_fneg_const_unary_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 = fneg float %y + %fma = call float @llvm.fma.f32(float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z) + ret float %fma +} + 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:%.*]]) @@ -72,6 +115,16 @@ define float @fma_fneg_x_fneg_const(float %x, float %z) { ret float %fma } +define float @fma_unary_fneg_x_unary_fneg_const(float %x, float %z) { +; CHECK-LABEL: @fma_unary_fneg_x_unary_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 = fneg float %x + %fma = call float @llvm.fma.f32(float %x.fneg, float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z) + ret float %fma +} + 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:%.*]]) @@ -116,6 +169,17 @@ define float @fmuladd_fneg_x_fneg_y(float %x, float %y, float %z) { ret float %fmuladd } +define float @fmuladd_unary_fneg_x_unary_fneg_y(float %x, float %y, float %z) { +; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_y( +; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]]) +; CHECK-NEXT: ret float [[FMULADD]] +; + %x.fneg = fneg float %x + %y.fneg = fneg float %y + %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z) + ret float %fmuladd +} + 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:%.*]] @@ -128,6 +192,18 @@ define float @fmuladd_fneg_x_fneg_y_fast(float %x, float %y, float %z) { ret float %fmuladd } +define float @fmuladd_unary_fneg_x_unary_fneg_y_fast(float %x, float %y, float %z) { +; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_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 = fneg float %x + %y.fneg = fneg float %y + %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z) + ret float %fmuladd +} + 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:%.*]]) @@ -138,6 +214,16 @@ define float @fmuladd_fneg_const_fneg_y(float %y, float %z) { ret float %fmuladd } +define float @fmuladd_unary_fneg_const_unary_fneg_y(float %y, float %z) { +; CHECK-LABEL: @fmuladd_unary_fneg_const_unary_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 = fneg float %y + %fmuladd = call float @llvm.fmuladd.f32(float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z) + ret float %fmuladd +} + 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:%.*]]) @@ -148,6 +234,16 @@ define float @fmuladd_fneg_x_fneg_const(float %x, float %z) { ret float %fmuladd } +define float @fmuladd_unary_fneg_x_unary_fneg_const(float %x, float %z) { +; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_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 = fneg float %x + %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z) + ret float %fmuladd +} + 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:%.*]]) -- 2.50.1