diff options
author | Richard Biener <rguenther@suse.de> | 2016-07-15 12:56:17 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-07-15 12:56:17 +0000 |
commit | 9513d5fbcabaf84b5e8450e8bb16894b3d42ba96 (patch) | |
tree | 56a686a80dbf024010fa6ae23366cee856981020 /gcc/tree-ssa-phiopt.c | |
parent | ad611a4c8401a0ba74501d6c289f881b3de82827 (diff) | |
download | gcc-9513d5fbcabaf84b5e8450e8bb16894b3d42ba96.zip gcc-9513d5fbcabaf84b5e8450e8bb16894b3d42ba96.tar.gz gcc-9513d5fbcabaf84b5e8450e8bb16894b3d42ba96.tar.bz2 |
re PR tree-optimization/71887 (wrong code (SIGFPE) at -O1 and above on x86_64-linux-gnu (in both 32-bit and 64-bit modes))
2016-07-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/71887
* tree-ssa-phiopt.c (absorbing_element_p): Add rhs arg and
verify it is not zero for division / modulo handling.
(value_replacement): Adjust.
* gcc.dg/torture/pr71887.c: New testcase.
From-SVN: r238373
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index dd9aa01..dd3837d 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -812,7 +812,7 @@ neutral_element_p (tree_code code, tree arg, bool right) /* Returns true if ARG is an absorbing element for operation CODE. */ static bool -absorbing_element_p (tree_code code, tree arg, bool right) +absorbing_element_p (tree_code code, tree arg, bool right, tree rval) { switch (code) { @@ -827,6 +827,8 @@ absorbing_element_p (tree_code code, tree arg, bool right) case RSHIFT_EXPR: case LROTATE_EXPR: case RROTATE_EXPR: + return !right && integer_zerop (arg); + case TRUNC_DIV_EXPR: case CEIL_DIV_EXPR: case FLOOR_DIV_EXPR: @@ -836,7 +838,9 @@ absorbing_element_p (tree_code code, tree arg, bool right) case CEIL_MOD_EXPR: case FLOOR_MOD_EXPR: case ROUND_MOD_EXPR: - return !right && integer_zerop (arg); + return (!right + && integer_zerop (arg) + && tree_single_nonzero_warnv_p (rval, NULL)); default: return false; @@ -1010,9 +1014,10 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, && neutral_element_p (code_def, cond_rhs, false)) || (operand_equal_for_phi_arg_p (arg1, cond_rhs) && ((operand_equal_for_phi_arg_p (rhs2, cond_lhs) - && absorbing_element_p (code_def, cond_rhs, true)) + && absorbing_element_p (code_def, cond_rhs, true, rhs2)) || (operand_equal_for_phi_arg_p (rhs1, cond_lhs) - && absorbing_element_p (code_def, cond_rhs, false)))))) + && absorbing_element_p (code_def, + cond_rhs, false, rhs2)))))) { gsi = gsi_for_stmt (cond); if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))) |