From 83573718611b7765722ee92b6bfda7313a918285 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 20 Feb 2018 23:34:43 +0000 Subject: [PATCH] [InstCombine] add tests for fdiv with negated op and constant op; NFC llvm-svn: 325644 --- llvm/test/Transforms/InstCombine/fdiv.ll | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index 02eb046..506deaa 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -213,6 +213,50 @@ define <2 x float> @fneg_fneg_vec(<2 x float> %x, <2 x float> %y) { ret <2 x float> %div } +define float @fneg_dividend_constant_divisor(float %x) { +; CHECK-LABEL: @fneg_dividend_constant_divisor( +; CHECK-NEXT: [[NEG:%.*]] = fsub float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[NEG]], 3.000000e+00 +; CHECK-NEXT: ret float [[DIV]] +; + %neg = fsub float -0.0, %x + %div = fdiv float %neg, 3.0 + ret float %div +} + +define float @fneg_divisor_constant_dividend(float %x) { +; CHECK-LABEL: @fneg_divisor_constant_dividend( +; CHECK-NEXT: [[NEG:%.*]] = fsub float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[DIV:%.*]] = fdiv float -3.000000e+00, [[NEG]] +; CHECK-NEXT: ret float [[DIV]] +; + %neg = fsub float -0.0, %x + %div = fdiv float -3.0, %neg + ret float %div +} + +define <2 x float> @fneg_dividend_constant_divisor_vec(<2 x float> %x) { +; CHECK-LABEL: @fneg_dividend_constant_divisor_vec( +; CHECK-NEXT: [[NEG:%.*]] = fsub <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[NEG]], +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %neg = fsub <2 x float> , %x + %div = fdiv <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: [[NEG:%.*]] = fsub <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> , [[NEG]] +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %neg = fsub <2 x float> , %x + %div = fdiv <2 x float> , %neg + ret <2 x float> %div +} + ; X / (X * Y) --> 1.0 / Y define float @div_factor(float %x, float %y) { -- 2.7.4