rs6000: Workaround for PR98092

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.
This commit is contained in:
Segher Boessenkool 2021-03-16 18:29:11 +00:00
parent d55ce33a34
commit a0b5843a9b
2 changed files with 12 additions and 4 deletions

View File

@ -1208,10 +1208,11 @@
(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")))

View File

@ -0,0 +1,7 @@
/* { dg-options "-mdejagnu-cpu=power9 -ffinite-math-only" } */
int
h9 (__attribute__ ((altivec (vector__))) char un)
{
return (__builtin_vec_bcdinvalid (un));
}