https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89445
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Something like:
--- gcc/simplify-rtx.c.jj 2019-01-10 11:43:14.390377646 +0100
+++ gcc/simplify-rtx.c 2019-02-22 17:54:36.633829649 +0100
@@ -6073,8 +6073,10 @@ simplify_ternary_operation (enum rtx_cod
if (!side_effects_p (op2))
{
- rtx top0 = simplify_merge_mask (op0, op2, 0);
- rtx top1 = simplify_merge_mask (op1, op2, 1);
+ rtx top0
+ = may_trap_p (op0) ? NULL_RTX : simplify_merge_mask (op0, op2, 0);
+ rtx top1
+ = may_trap_p (op1) ? NULL_RTX : simplify_merge_mask (op1, op2, 1);
if (top0 || top1)
return simplify_gen_ternary (code, mode, mode,
top0 ? top0 : op0,
fixes this, except that it seems may_trap_p_1 isn't really ready to handle
vectors (or do they never trap, that would surprise me).
E.g.
default:
/* Any floating arithmetic may trap. */
if (SCALAR_FLOAT_MODE_P (GET_MODE (x)) && flag_trapping_math)
return 1;
Shouldn't that really be FLOAT_MODE_P instead of SCALAR_FLOAT_MODE_P?
For DIV etc. the above plus:
if (!CONSTANT_P (XEXP (x, 1)) || (XEXP (x, 1) == const0_rtx))
return 1;
wouldn't we want test for vector integer divisions (does any target have them,
maybe mips?) if all the elements of a CONST_VECTOR are non-zero?