[llvm] ac2f13f - [InstSimplify] add tests for vectors with SNaN constants; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 16:11:22 PST 2023


Author: Sanjay Patel
Date: 2023-02-14T19:10:56-05:00
New Revision: ac2f13f673b8a9f336cf6d9569ab07fc3629eaab

URL: https://github.com/llvm/llvm-project/commit/ac2f13f673b8a9f336cf6d9569ab07fc3629eaab
DIFF: https://github.com/llvm/llvm-project/commit/ac2f13f673b8a9f336cf6d9569ab07fc3629eaab.diff

LOG: [InstSimplify] add tests for vectors with SNaN constants; NFC

Coverage for extension of functionality from D143505.

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/fp-nan.ll
    llvm/test/Transforms/InstSimplify/strictfp-fadd.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/fp-nan.ll b/llvm/test/Transforms/InstSimplify/fp-nan.ll
index 25d3a0affed8..37760a6ecf20 100644
--- a/llvm/test/Transforms/InstSimplify/fp-nan.ll
+++ b/llvm/test/Transforms/InstSimplify/fp-nan.ll
@@ -41,6 +41,14 @@ define float @fsub_nan_op1(float %x) {
   ret float %r
 }
 
+define <2 x float> @fsub_nan_op1_vec(<2 x float> %x) {
+; CHECK-LABEL: @fsub_nan_op1_vec(
+; CHECK-NEXT:    ret <2 x float> <float 0x7FF1000000000000, float 0xFFF1000000000000>
+;
+  %r = fsub <2 x float> %x, <float 0x7FF1000000000000, float 0xFFF1000000000000>
+  ret <2 x float> %r
+}
+
 ; Signaling and signed - make quiet and preserve the payload and signbit
 
 define double @fmul_nan_op0(double %x) {
@@ -51,6 +59,14 @@ define double @fmul_nan_op0(double %x) {
   ret double %r
 }
 
+define <2 x double> @fmul_nan_op0_vec(<2 x double> %x) {
+; CHECK-LABEL: @fmul_nan_op0_vec(
+; CHECK-NEXT:    ret <2 x double> <double 0xFFF0000000000001, double 0xFFF0DEADDEADDEAD>
+;
+  %r = fmul <2 x double> <double 0xFFF0000000000001, double 0xFFF0DEADDEADDEAD>, %x
+  ret <2 x double> %r
+}
+
 ; Vector type
 
 define <2 x float> @fmul_nan_op1(<2 x float> %x) {

diff  --git a/llvm/test/Transforms/InstSimplify/strictfp-fadd.ll b/llvm/test/Transforms/InstSimplify/strictfp-fadd.ll
index f27e430c6866..24889b1cdd21 100644
--- a/llvm/test/Transforms/InstSimplify/strictfp-fadd.ll
+++ b/llvm/test/Transforms/InstSimplify/strictfp-fadd.ll
@@ -390,6 +390,46 @@ define float @fold_fadd_snan_variable_ebmaytrap(float %x) #0 {
   ret float %add
 }
 
+; FIXME: Exceptions are ignored, so this can be folded, but constrained math requires that SNaN is quieted per IEEE-754 spec.
+
+define <2 x float> @fold_fadd_vec_snan_variable_ebignore(<2 x float> %x) #0 {
+; CHECK-LABEL: @fold_fadd_vec_snan_variable_ebignore(
+; CHECK-NEXT:    ret <2 x float> <float 0x7FF4000000000000, float 0xFFF4000000000000>
+;
+  %add = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float 0x7ff4000000000000, float 0xfff4000000000000>, <2 x float> %x, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
+  ret <2 x float> %add
+}
+
+; FIXME: Exceptions may (not) trap, so this can be folded, but constrained math requires that SNaN is quieted per IEEE-754 spec.
+
+define <2 x float> @fold_fadd_vec_snan_variable_ebmaytrap(<2 x float> %x) #0 {
+; CHECK-LABEL: @fold_fadd_vec_snan_variable_ebmaytrap(
+; CHECK-NEXT:    ret <2 x float> <float 0xFFF4000000000000, float 0x7FF4000000000000>
+;
+  %add = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float 0xfff4000000000000, float 0x7ff4000000000000>, <2 x float> %x, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
+  ret <2 x float> %add
+}
+
+; FIXME: Exceptions are ignored, so this can be folded, but constrained math requires that SNaN is quieted per IEEE-754 spec.
+
+define <2 x float> @fold_fadd_vec_partial_snan_variable_ebignore(<2 x float> %x) #0 {
+; CHECK-LABEL: @fold_fadd_vec_partial_snan_variable_ebignore(
+; CHECK-NEXT:    ret <2 x float> <float 0x7FF4000000000000, float 0xFFFF000000000000>
+;
+  %add = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float 0x7ff4000000000000, float 0xffff000000000000>, <2 x float> %x, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
+  ret <2 x float> %add
+}
+
+; FIXME: Exceptions may (not) trap, so this can be folded, but constrained math requires that SNaN is quieted per IEEE-754 spec.
+
+define <2 x float> @fold_fadd_vec_partial_snan_variable_ebmaytrap(<2 x float> %x) #0 {
+; CHECK-LABEL: @fold_fadd_vec_partial_snan_variable_ebmaytrap(
+; CHECK-NEXT:    ret <2 x float> <float 0xFFF8000000000000, float 0x7FF4000000000000>
+;
+  %add = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float 0xfff8000000000000, float 0x7ff4000000000000>, <2 x float> %x, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
+  ret <2 x float> %add
+}
+
 define float @fold_fadd_snan_variable_ebstrict(float %x) #0 {
 ; CHECK-LABEL: @fold_fadd_snan_variable_ebstrict(
 ; CHECK-NEXT:    [[ADD:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float 0x7FF4000000000000, float [[X:%.*]], metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]


        


More information about the llvm-commits mailing list