[llvm] dc17325 - [InstCombine] add tests for FMF propagation via -(C/X); NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 7 10:22:57 PDT 2021
Author: Sanjay Patel
Date: 2021-06-07T13:22:49-04:00
New Revision: dc173254e754f1c363218548040642c6c53da8ed
URL: https://github.com/llvm/llvm-project/commit/dc173254e754f1c363218548040642c6c53da8ed
DIFF: https://github.com/llvm/llvm-project/commit/dc173254e754f1c363218548040642c6c53da8ed.diff
LOG: [InstCombine] add tests for FMF propagation via -(C/X); NFC
There are bugs here as discussed in:
https://llvm.org/PR49654
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 0d56fbf50bdf4..62d2f105e69c8 100644
--- a/llvm/test/Transforms/InstCombine/fneg.ll
+++ b/llvm/test/Transforms/InstCombine/fneg.ll
@@ -225,18 +225,18 @@ define float @fdiv_op0_constant_fneg(float %x) {
; Fast math is not required, but it should be propagated.
-define float @fdiv_op0_constant_fsub_fmf(float %x) {
-; CHECK-LABEL: @fdiv_op0_constant_fsub_fmf(
+define float @fdiv_op0_constant_fneg_fast_fast(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_fast_fast(
; CHECK-NEXT: [[R:%.*]] = fdiv fast float -4.200000e+01, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
- %d = fdiv float 42.0, %x
- %r = fsub fast float -0.0, %d
+ %d = fdiv fast float 42.0, %x
+ %r = fneg fast float %d
ret float %r
}
-define float @fdiv_op0_constant_fneg_fmf(float %x) {
-; CHECK-LABEL: @fdiv_op0_constant_fneg_fmf(
+define float @fdiv_op0_constant_fneg_fast(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_fast(
; CHECK-NEXT: [[R:%.*]] = fdiv fast float -4.200000e+01, [[X:%.*]]
; CHECK-NEXT: ret float [[R]]
;
@@ -245,6 +245,66 @@ define float @fdiv_op0_constant_fneg_fmf(float %x) {
ret float %r
}
+define float @fdiv_op0_constant_fneg_nsz_nsz(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_nsz_nsz(
+; CHECK-NEXT: [[R:%.*]] = fdiv nsz float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %d = fdiv nsz float 42.0, %x
+ %r = fneg nsz float %d
+ ret float %r
+}
+
+define float @fdiv_op0_constant_fneg_nsz(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_nsz(
+; CHECK-NEXT: [[R:%.*]] = fdiv nsz float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %d = fdiv float 42.0, %x
+ %r = fneg nsz float %d
+ ret float %r
+}
+
+define float @fdiv_op0_constant_fneg_ninf_ninf(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_ninf_ninf(
+; CHECK-NEXT: [[R:%.*]] = fdiv ninf float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %d = fdiv ninf float 42.0, %x
+ %r = fneg ninf float %d
+ ret float %r
+}
+
+define float @fdiv_op0_constant_fneg_ninf(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_ninf(
+; CHECK-NEXT: [[R:%.*]] = fdiv ninf float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %d = fdiv float 42.0, %x
+ %r = fneg ninf float %d
+ ret float %r
+}
+
+define float @fdiv_op0_constant_fneg_nnan_nnan(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_nnan_nnan(
+; CHECK-NEXT: [[R:%.*]] = fdiv nnan float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %d = fdiv nnan float 42.0, %x
+ %r = fneg nnan float %d
+ ret float %r
+}
+
+define float @fdiv_op0_constant_fneg_nnan(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_nnan(
+; CHECK-NEXT: [[R:%.*]] = fdiv nnan float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %d = fdiv float 42.0, %x
+ %r = fneg nnan float %d
+ ret float %r
+}
+
; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
define float @fdiv_op0_constant_fsub_extra_use(float %x) {
More information about the llvm-commits
mailing list