diff mbox series

rs6000: Workaround for PR98092

Message ID cb1839a86c45a03d8c32bcbf32be29248cd11e66.1615922007.git.segher@kernel.crashing.org
State New
Headers show
Series rs6000: Workaround for PR98092 | expand

Commit Message

Segher Boessenkool March 16, 2021, 7:20 p.m. UTC
The bcdinvalid_<mode> RTL instruction uses the "unordered" comparison,
which cannot be used if we have -ffinite-math-only.  We really need
CCMODEs that describe what bits in a CR field are set by other insns
than just comparisons, but that is a lot more surgery, and it is stage 4
now.  This patch does a simple workaround.

2021-03-16  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/98092
	* config/rs6000/predicates.md (branch_comparison_operator): Allow
	ordered and unordered for CCFPmode, if flag_finite_math_only.

gcc/testsuite/
	PR target/98092
	* gcc.target/powerpc/pr98092.c: New.
---
 gcc/config/rs6000/predicates.md            | 9 +++++----
 gcc/testsuite/gcc.target/powerpc/pr98092.c | 7 +++++++
 2 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr98092.c
diff mbox series

Patch

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index 69f3c709abbc..859af75dfbd1 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -1208,10 +1208,11 @@  (define_special_predicate "equality_operator"
 (define_predicate "branch_comparison_operator"
    (and (match_operand 0 "comparison_operator")
 	(match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
-	(if_then_else (match_test "GET_MODE (XEXP (op, 0)) == CCFPmode
-				   && !flag_finite_math_only")
-		      (match_code "lt,gt,eq,unordered,unge,unle,ne,ordered")
-		      (match_code "lt,ltu,le,leu,gt,gtu,ge,geu,eq,ne"))
+	(if_then_else (match_test "GET_MODE (XEXP (op, 0)) == CCFPmode")
+	  (if_then_else (match_test "flag_finite_math_only")
+	    (match_code "lt,le,gt,ge,eq,ne,unordered,ordered")
+	    (match_code "lt,gt,eq,unordered,unge,unle,ne,ordered"))
+	  (match_code "lt,ltu,le,leu,gt,gtu,ge,geu,eq,ne"))
 	(match_test "validate_condition_mode (GET_CODE (op),
 					      GET_MODE (XEXP (op, 0))),
 		     1")))
diff --git a/gcc/testsuite/gcc.target/powerpc/pr98092.c b/gcc/testsuite/gcc.target/powerpc/pr98092.c
new file mode 100644
index 000000000000..03eab5a24ef7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr98092.c
@@ -0,0 +1,7 @@ 
+/* { dg-options "-mdejagnu-cpu=power9 -ffinite-math-only" } */
+
+int
+h9 (__attribute__ ((altivec (vector__))) char un)
+{
+  return (__builtin_vec_bcdinvalid (un));
+}