From c52ed5c4f1f2a2e54634226dc6bd305f98f0c541 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 8 Jun 2021 16:06:10 -0400 Subject: [PATCH] [InstCombine] add FMF tests for fneg-of-select; NFC As noted in the post-commit comments for 3cdd05e519d, we need to be more careful about FMF propagation. --- llvm/test/Transforms/InstCombine/fneg.ll | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/fneg.ll b/llvm/test/Transforms/InstCombine/fneg.ll index 50371f6..6d507bd 100644 --- a/llvm/test/Transforms/InstCombine/fneg.ll +++ b/llvm/test/Transforms/InstCombine/fneg.ll @@ -588,6 +588,30 @@ define <2 x float> @select_fneg_false(<2 x float> %x, <2 x float> %y, <2 x i1> % ret <2 x float> %r } +define float @select_fneg_false_no_nsz(float %x, float %y, i1 %b) { +; CHECK-LABEL: @select_fneg_false_no_nsz( +; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan ninf nsz float [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = select nnan ninf nsz i1 [[B:%.*]], float [[X_NEG]], float [[Y:%.*]] +; CHECK-NEXT: ret float [[TMP1]] +; + %ny = fneg float %y + %s = select i1 %b, float %x, float %ny + %r = fneg ninf nnan nsz float %s + ret float %r +} + +define float @select_fneg_false_nsz(float %x, float %y, i1 %b) { +; CHECK-LABEL: @select_fneg_false_nsz( +; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan ninf nsz float [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = select nnan ninf nsz i1 [[B:%.*]], float [[X_NEG]], float [[Y:%.*]] +; CHECK-NEXT: ret float [[TMP1]] +; + %ny = fneg float %y + %s = select nsz i1 %b, float %x, float %ny + %r = fneg ninf nnan nsz float %s + ret float %r +} + define float @select_fneg_both(float %x, float %y, i1 %b) { ; CHECK-LABEL: @select_fneg_both( ; CHECK-NEXT: [[S_V:%.*]] = select i1 [[B:%.*]], float [[X:%.*]], float [[Y:%.*]] -- 2.7.4