From bc920450136acfec7342162eb95c39f52dc91a23 Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Tue, 7 Jun 2022 11:00:33 +0100 Subject: [PATCH] [NFC][InstCombine] Add two more tests to select-binop-foldable-floating-point.ll Pre-commit some tests as part of https://reviews.llvm.org/D126774 --- .../select-binop-foldable-floating-point.ll | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/select-binop-foldable-floating-point.ll b/llvm/test/Transforms/InstCombine/select-binop-foldable-floating-point.ll index b65bf26..00360b2 100644 --- a/llvm/test/Transforms/InstCombine/select-binop-foldable-floating-point.ll +++ b/llvm/test/Transforms/InstCombine/select-binop-foldable-floating-point.ll @@ -133,6 +133,28 @@ define float @select_fsub_swapped_fast_math(i1 %cond, float %A, float %B) { ret float %D } +define <4 x float> @select_nsz_fsub_v4f32(<4 x i1> %cond, <4 x float> %A, <4 x float> %B) { +; CHECK-LABEL: @select_nsz_fsub_v4f32( +; CHECK-NEXT: [[C:%.*]] = select <4 x i1> [[COND:%.*]], <4 x float> [[B:%.*]], <4 x float> zeroinitializer +; CHECK-NEXT: [[D:%.*]] = fsub <4 x float> [[A:%.*]], [[C]] +; CHECK-NEXT: ret <4 x float> [[D]] +; + %C = fsub <4 x float> %A, %B + %D = select nsz <4 x i1> %cond, <4 x float> %C, <4 x float> %A + ret <4 x float> %D +} + +define @select_nsz_fsub_nxv4f32( %cond, %A, %B) { +; CHECK-LABEL: @select_nsz_fsub_nxv4f32( +; CHECK-NEXT: [[C:%.*]] = select [[COND:%.*]], [[B:%.*]], zeroinitializer +; CHECK-NEXT: [[D:%.*]] = fsub [[A:%.*]], [[C]] +; CHECK-NEXT: ret [[D]] +; + %C = fsub %A, %B + %D = select nsz %cond, %C, %A + ret %D +} + ; 'fsub' can only fold on the amount subtracted. define float @select_fsub_invalid(i1 %cond, float %A, float %B) { ; CHECK-LABEL: @select_fsub_invalid( -- 2.7.4