[llvm] 2d3593e - [InstCombine] add tests for fneg-of-select with FMF; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 08:05:39 PDT 2022
Author: Sanjay Patel
Date: 2022-03-15T11:05:29-04:00
New Revision: 2d3593e6683d5a7df242ac339c357ff980f201da
URL: https://github.com/llvm/llvm-project/commit/2d3593e6683d5a7df242ac339c357ff980f201da
DIFF: https://github.com/llvm/llvm-project/commit/2d3593e6683d5a7df242ac339c357ff980f201da.diff
LOG: [InstCombine] add tests for fneg-of-select with FMF; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/fneg.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/fneg.ll b/llvm/test/Transforms/InstCombine/fneg.ll
index b8df66ee74aa7..2af1e6ea26b5b 100644
--- a/llvm/test/Transforms/InstCombine/fneg.ll
+++ b/llvm/test/Transforms/InstCombine/fneg.ll
@@ -674,6 +674,58 @@ define float @select_fneg_false_nsz(float %x, float %y, i1 %b) {
ret float %r
}
+define float @select_common_op_fneg_true(float %x, i1 %b) {
+; CHECK-LABEL: @select_common_op_fneg_true(
+; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan ninf nsz float [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select nnan ninf i1 [[B:%.*]], float [[X_NEG]], float [[X]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %nx = fneg float %x
+ %s = select i1 %b, float %x, float %nx
+ %r = fneg nsz ninf nnan float %s
+ ret float %r
+}
+
+define float @select_common_op_fneg_false(float %x, i1 %b) {
+; CHECK-LABEL: @select_common_op_fneg_false(
+; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan ninf nsz float [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select nnan ninf i1 [[B:%.*]], float [[X_NEG]], float [[X]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %nx = fneg float %x
+ %s = select i1 %b, float %x, float %nx
+ %r = fneg nsz ninf nnan float %s
+ ret float %r
+}
+
+define float @fabs(float %a) {
+; CHECK-LABEL: @fabs(
+; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[A:%.*]], 0.000000e+00
+; CHECK-NEXT: [[A_NEG:%.*]] = fneg nnan ninf nsz float [[A]]
+; CHECK-NEXT: [[FNEG1:%.*]] = select nnan ninf i1 [[CMP]], float [[A]], float [[A_NEG]]
+; CHECK-NEXT: ret float [[FNEG1]]
+;
+ %fneg = fneg float %a
+ %cmp = fcmp ogt float %a, %fneg
+ %sel = select i1 %cmp, float %fneg, float %a
+ %fneg1 = fneg nnan ninf nsz float %sel
+ ret float %fneg1
+}
+
+define float @fnabs(float %a) {
+; CHECK-LABEL: @fnabs(
+; CHECK-NEXT: [[CMP:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; CHECK-NEXT: [[A_NEG:%.*]] = fneg fast float [[A]]
+; CHECK-NEXT: [[FNEG1:%.*]] = select reassoc nnan ninf arcp contract afn i1 [[CMP]], float [[A]], float [[A_NEG]]
+; CHECK-NEXT: ret float [[FNEG1]]
+;
+ %fneg = fneg float %a
+ %cmp = fcmp olt float %a, %fneg
+ %sel = select i1 %cmp, float %fneg, float %a
+ %fneg1 = fneg fast float %sel
+ ret float %fneg1
+}
+
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:%.*]]
More information about the llvm-commits
mailing list