From 66911b16e66f72454d9668db9d627fc588823b78 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 26 Feb 2018 23:23:02 +0000 Subject: [PATCH] [InstCombine, InstSimplify] add tests with undef elements in constant FP vectors; NFC llvm-svn: 326148 --- llvm/test/Transforms/InstCombine/fdiv.ll | 33 +++++++++++++++++++ .../InstSimplify/floating-point-arithmetic.ll | 29 ++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index 8073371c16b4..9e265d2135ff 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -122,6 +122,15 @@ define <2 x float> @not_exact_inverse_vec_arcp(<2 x float> %x) { ret <2 x float> %div } +define <2 x float> @not_exact_inverse_vec_arcp_with_undef_elt(<2 x float> %x) { +; CHECK-LABEL: @not_exact_inverse_vec_arcp_with_undef_elt( +; CHECK-NEXT: [[DIV:%.*]] = fdiv arcp <2 x float> [[X:%.*]], +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %div = fdiv arcp <2 x float> %x, + ret <2 x float> %div +} + ; (X / Y) / Z --> X / (Y * Z) define float @div_with_div_numerator(float %x, float %y, float %z) { @@ -213,6 +222,19 @@ define <2 x float> @fneg_fneg_vec(<2 x float> %x, <2 x float> %y) { ret <2 x float> %div } +define <2 x float> @fneg_fneg_vec_undef_elts(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @fneg_fneg_vec_undef_elts( +; CHECK-NEXT: [[XNEG:%.*]] = fsub <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[YNEG:%.*]] = fsub <2 x float> , [[Y:%.*]] +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[XNEG]], [[YNEG]] +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %xneg = fsub <2 x float> , %x + %yneg = fsub <2 x float> , %y + %div = fdiv <2 x float> %xneg, %yneg + ret <2 x float> %div +} + define float @fneg_dividend_constant_divisor(float %x) { ; CHECK-LABEL: @fneg_dividend_constant_divisor( ; CHECK-NEXT: [[DIV:%.*]] = fdiv nsz float [[X:%.*]], -3.000000e+00 @@ -243,6 +265,17 @@ define <2 x float> @fneg_dividend_constant_divisor_vec(<2 x float> %x) { ret <2 x float> %div } +define <2 x float> @fneg_dividend_constant_divisor_vec_undef_elt(<2 x float> %x) { +; CHECK-LABEL: @fneg_dividend_constant_divisor_vec_undef_elt( +; CHECK-NEXT: [[NEG:%.*]] = fsub <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf <2 x float> [[NEG]], +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %neg = fsub <2 x float> , %x + %div = fdiv ninf <2 x float> %neg, + ret <2 x float> %div +} + define <2 x float> @fneg_divisor_constant_dividend_vec(<2 x float> %x) { ; CHECK-LABEL: @fneg_divisor_constant_dividend_vec( ; CHECK-NEXT: [[DIV:%.*]] = fdiv afn <2 x float> , [[X:%.*]] diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll index ba177ead7185..d564992e2d83 100644 --- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll +++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll @@ -11,6 +11,26 @@ define float @fsub_-0_-0_x(float %a) { ret float %ret } +define <2 x float> @fsub_-0_-0_x_vec(<2 x float> %a) { +; CHECK-LABEL: @fsub_-0_-0_x_vec( +; CHECK-NEXT: ret <2 x float> [[A:%.*]] +; + %t1 = fsub <2 x float> , %a + %ret = fsub <2 x float> , %t1 + ret <2 x float> %ret +} + +define <2 x float> @fsub_-0_-0_x_vec_undef_elts(<2 x float> %a) { +; CHECK-LABEL: @fsub_-0_-0_x_vec_undef_elts( +; CHECK-NEXT: [[T1:%.*]] = fsub <2 x float> , [[A:%.*]] +; CHECK-NEXT: [[RET:%.*]] = fsub <2 x float> , [[T1]] +; CHECK-NEXT: ret <2 x float> [[RET]] +; + %t1 = fsub <2 x float> , %a + %ret = fsub <2 x float> , %t1 + ret <2 x float> %ret +} + ; fsub 0.0, (fsub -0.0, X) != X define float @fsub_0_-0_x(float %a) { ; CHECK-LABEL: @fsub_0_-0_x( @@ -53,6 +73,15 @@ define float @fadd_x_n0(float %a) { ret float %ret } +define <2 x float> @fadd_x_n0_vec_undef_elt(<2 x float> %a) { +; CHECK-LABEL: @fadd_x_n0_vec_undef_elt( +; CHECK-NEXT: [[RET:%.*]] = fadd <2 x float> [[A:%.*]], +; CHECK-NEXT: ret <2 x float> [[RET]] +; + %ret = fadd <2 x float> %a, + ret <2 x float> %ret +} + ; fmul X, 1.0 ==> X define double @fmul_X_1(double %a) { ; CHECK-LABEL: @fmul_X_1(