From aeafce571950d364393749e0c7c62c0a09c9632c Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Mon, 24 Jun 2019 21:36:09 +0000 Subject: [PATCH] [NFC][Reassociate] Add unary FNeg tests to fast-ReassociateVector.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364232 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Reassociate/fast-ReassociateVector.ll | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/Transforms/Reassociate/fast-ReassociateVector.ll b/test/Transforms/Reassociate/fast-ReassociateVector.ll index b6926273249..a3d8f32c162 100644 --- a/test/Transforms/Reassociate/fast-ReassociateVector.ll +++ b/test/Transforms/Reassociate/fast-ReassociateVector.ll @@ -232,6 +232,19 @@ define <2 x double> @test9(<2 x double> %b, <2 x double> %a) { ret <2 x double> %4 } +define <2 x double> @test9_unary_fneg(<2 x double> %b, <2 x double> %a) { +; CHECK-LABEL: @test9_unary_fneg( +; CHECK-NEXT: [[TMP1:%.*]] = fneg fast <2 x double> [[A:%.*]] +; CHECK-NEXT: [[TMP2:%.*]] = fadd fast <2 x double> [[B:%.*]], +; CHECK-NEXT: ret <2 x double> [[TMP2]] +; + %1 = fadd fast <2 x double> %a, + %2 = fadd fast <2 x double> %b, %1 + %3 = fneg fast <2 x double> %a + %4 = fadd fast <2 x double> %2, %3 + ret <2 x double> %4 +} + ; Check (b+(a+1234))+-a -> b+1234 - minimum FMF subset version define <2 x double> @test9_reassoc(<2 x double> %b, <2 x double> %a) { @@ -249,6 +262,21 @@ define <2 x double> @test9_reassoc(<2 x double> %b, <2 x double> %a) { ret <2 x double> %4 } +define <2 x double> @test9_reassoc_unary_fneg(<2 x double> %b, <2 x double> %a) { +; CHECK-LABEL: @test9_reassoc_unary_fneg( +; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc <2 x double> [[A:%.*]], +; CHECK-NEXT: [[TMP2:%.*]] = fadd reassoc <2 x double> [[B:%.*]], [[TMP1]] +; CHECK-NEXT: [[TMP3:%.*]] = fneg reassoc <2 x double> [[A]] +; CHECK-NEXT: [[TMP4:%.*]] = fadd reassoc <2 x double> [[TMP3]], [[TMP2]] +; CHECK-NEXT: ret <2 x double> [[TMP4]] +; + %1 = fadd reassoc <2 x double> %a, + %2 = fadd reassoc <2 x double> %b, %1 + %3 = fneg reassoc <2 x double> %a + %4 = fadd reassoc <2 x double> %2, %3 + ret <2 x double> %4 +} + ; Check -(-(z*40)*a) -> a*40*z. define <2 x float> @test10(<2 x float> %a, <2 x float> %b, <2 x float> %z) { @@ -265,6 +293,20 @@ define <2 x float> @test10(<2 x float> %a, <2 x float> %b, <2 x float> %z) { ret <2 x float> %f } +define <2 x float> @test10_unary_fneg(<2 x float> %a, <2 x float> %b, <2 x float> %z) { +; CHECK-LABEL: @test10_unary_fneg( +; CHECK-NEXT: [[TMP1:%.*]] = fneg fast <2 x float> zeroinitializer +; CHECK-NEXT: [[E:%.*]] = fmul fast <2 x float> [[A:%.*]], +; CHECK-NEXT: [[F:%.*]] = fmul fast <2 x float> [[E]], [[Z:%.*]] +; CHECK-NEXT: ret <2 x float> [[F]] +; + %d = fmul fast <2 x float> %z, + %c = fneg fast <2 x float> %d + %e = fmul fast <2 x float> %a, %c + %f = fneg fast <2 x float> %e + ret <2 x float> %f +} + ; Check -(-(z*40)*a) -> a*40*z - minimum FMF subset version define <2 x float> @test10_reassoc(<2 x float> %a, <2 x float> %b, <2 x float> %z) { @@ -282,6 +324,21 @@ define <2 x float> @test10_reassoc(<2 x float> %a, <2 x float> %b, <2 x float> % ret <2 x float> %f } +define <2 x float> @test10_reassoc_unary_fneg(<2 x float> %a, <2 x float> %b, <2 x float> %z) { +; CHECK-LABEL: @test10_reassoc_unary_fneg( +; CHECK-NEXT: [[D:%.*]] = fmul reassoc <2 x float> [[Z:%.*]], +; CHECK-NEXT: [[C:%.*]] = fneg reassoc <2 x float> [[D]] +; CHECK-NEXT: [[E:%.*]] = fmul reassoc <2 x float> [[A:%.*]], [[C]] +; CHECK-NEXT: [[F:%.*]] = fneg reassoc <2 x float> [[E]] +; CHECK-NEXT: ret <2 x float> [[F]] +; + %d = fmul reassoc <2 x float> %z, + %c = fneg reassoc <2 x float> %d + %e = fmul reassoc <2 x float> %a, %c + %f = fneg reassoc <2 x float> %e + ret <2 x float> %f +} + ; Check x*y+y*x -> x*y*2. define <2 x double> @test11(<2 x double> %x, <2 x double> %y) { -- 2.11.0