aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorBernd Schmidt <bernds@redhat.com>2017-01-23 16:30:55 +0000
committerBernd Schmidt <bernds@gcc.gnu.org>2017-01-23 16:30:55 +0000
commit427ed3ae3ed40c00540af45ecc15a2d1f4058268 (patch)
treec331f74d4cc2a795f59daef6006982091f4a2dba /gcc/combine.c
parente9c4fbe9c1eff61ffe2aa31c67cef2ffd346f674 (diff)
downloadgcc-427ed3ae3ed40c00540af45ecc15a2d1f4058268.zip
gcc-427ed3ae3ed40c00540af45ecc15a2d1f4058268.tar.gz
gcc-427ed3ae3ed40c00540af45ecc15a2d1f4058268.tar.bz2
re PR rtl-optimization/71724 (ICE: Segmentation fault, deep recursion between combine_simplify_rtx and subst)
PR rtl-optimization/71724 * combine.c (if_then_else_cond): Look for situations where it is beneficial to undo the work of one of the recursive calls. From-SVN: r244817
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 28133ff..c643a0e 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -9044,11 +9044,31 @@ if_then_else_cond (rtx x, rtx *ptrue, rtx *pfalse)
the same value, compute the new true and false values. */
else if (BINARY_P (x))
{
- cond0 = if_then_else_cond (XEXP (x, 0), &true0, &false0);
- cond1 = if_then_else_cond (XEXP (x, 1), &true1, &false1);
+ rtx op0 = XEXP (x, 0);
+ rtx op1 = XEXP (x, 1);
+ cond0 = if_then_else_cond (op0, &true0, &false0);
+ cond1 = if_then_else_cond (op1, &true1, &false1);
+
+ if ((cond0 != 0 && cond1 != 0 && !rtx_equal_p (cond0, cond1))
+ && (REG_P (op0) || REG_P (op1)))
+ {
+ /* Try to enable a simplification by undoing work done by
+ if_then_else_cond if it converted a REG into something more
+ complex. */
+ if (REG_P (op0))
+ {
+ cond0 = 0;
+ true0 = false0 = op0;
+ }
+ else
+ {
+ cond1 = 0;
+ true1 = false1 = op1;
+ }
+ }
if ((cond0 != 0 || cond1 != 0)
- && ! (cond0 != 0 && cond1 != 0 && ! rtx_equal_p (cond0, cond1)))
+ && ! (cond0 != 0 && cond1 != 0 && !rtx_equal_p (cond0, cond1)))
{
/* If if_then_else_cond returned zero, then true/false are the
same rtl. We must copy one of them to prevent invalid rtl