[InstSimplify] add tests for vectors with SNaN constants; NFC
authorSanjay Patel <spatel@rotateright.com>
Tue, 14 Feb 2023 23:07:34 +0000 (18:07 -0500)
committerSanjay Patel <spatel@rotateright.com>
Wed, 15 Feb 2023 00:10:56 +0000 (19:10 -0500)
Coverage for extension of functionality from D143505.

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

index 25d3a0a..37760a6 100644 (file)
@@ -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) {
index f27e430..24889b1 100644 (file)
@@ -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]]