[PATCH][combine][1/2] Try to simplify before substituting
* combine.c (combine_simplify_rtx): Move simplification step before various transformations/substitutions. From-SVN: r225996
This commit is contained in:
parent
df2a7a38f6
commit
232c93296d
|
@ -1,3 +1,8 @@
|
||||||
|
2015-07-20 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
||||||
|
|
||||||
|
* combine.c (combine_simplify_rtx): Move simplification step
|
||||||
|
before various transformations/substitutions.
|
||||||
|
|
||||||
2015-07-20 Mikhail Maltsev <maltsevm@gmail.com>
|
2015-07-20 Mikhail Maltsev <maltsevm@gmail.com>
|
||||||
|
|
||||||
* wide-int.h (struct binary_traits): Fix partial specialization syntax.
|
* wide-int.h (struct binary_traits): Fix partial specialization syntax.
|
||||||
|
|
|
@ -5489,6 +5489,51 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
|
||||||
SUBST (XEXP (x, 1), temp);
|
SUBST (XEXP (x, 1), temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try to fold this expression in case we have constants that weren't
|
||||||
|
present before. */
|
||||||
|
temp = 0;
|
||||||
|
switch (GET_RTX_CLASS (code))
|
||||||
|
{
|
||||||
|
case RTX_UNARY:
|
||||||
|
if (op0_mode == VOIDmode)
|
||||||
|
op0_mode = GET_MODE (XEXP (x, 0));
|
||||||
|
temp = simplify_unary_operation (code, mode, XEXP (x, 0), op0_mode);
|
||||||
|
break;
|
||||||
|
case RTX_COMPARE:
|
||||||
|
case RTX_COMM_COMPARE:
|
||||||
|
{
|
||||||
|
machine_mode cmp_mode = GET_MODE (XEXP (x, 0));
|
||||||
|
if (cmp_mode == VOIDmode)
|
||||||
|
{
|
||||||
|
cmp_mode = GET_MODE (XEXP (x, 1));
|
||||||
|
if (cmp_mode == VOIDmode)
|
||||||
|
cmp_mode = op0_mode;
|
||||||
|
}
|
||||||
|
temp = simplify_relational_operation (code, mode, cmp_mode,
|
||||||
|
XEXP (x, 0), XEXP (x, 1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RTX_COMM_ARITH:
|
||||||
|
case RTX_BIN_ARITH:
|
||||||
|
temp = simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x, 1));
|
||||||
|
break;
|
||||||
|
case RTX_BITFIELD_OPS:
|
||||||
|
case RTX_TERNARY:
|
||||||
|
temp = simplify_ternary_operation (code, mode, op0_mode, XEXP (x, 0),
|
||||||
|
XEXP (x, 1), XEXP (x, 2));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp)
|
||||||
|
{
|
||||||
|
x = temp;
|
||||||
|
code = GET_CODE (temp);
|
||||||
|
op0_mode = VOIDmode;
|
||||||
|
mode = GET_MODE (temp);
|
||||||
|
}
|
||||||
|
|
||||||
/* If this is a simple operation applied to an IF_THEN_ELSE, try
|
/* If this is a simple operation applied to an IF_THEN_ELSE, try
|
||||||
applying it to the arms of the IF_THEN_ELSE. This often simplifies
|
applying it to the arms of the IF_THEN_ELSE. This often simplifies
|
||||||
things. Check for cases where both arms are testing the same
|
things. Check for cases where both arms are testing the same
|
||||||
|
@ -5588,51 +5633,6 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to fold this expression in case we have constants that weren't
|
|
||||||
present before. */
|
|
||||||
temp = 0;
|
|
||||||
switch (GET_RTX_CLASS (code))
|
|
||||||
{
|
|
||||||
case RTX_UNARY:
|
|
||||||
if (op0_mode == VOIDmode)
|
|
||||||
op0_mode = GET_MODE (XEXP (x, 0));
|
|
||||||
temp = simplify_unary_operation (code, mode, XEXP (x, 0), op0_mode);
|
|
||||||
break;
|
|
||||||
case RTX_COMPARE:
|
|
||||||
case RTX_COMM_COMPARE:
|
|
||||||
{
|
|
||||||
machine_mode cmp_mode = GET_MODE (XEXP (x, 0));
|
|
||||||
if (cmp_mode == VOIDmode)
|
|
||||||
{
|
|
||||||
cmp_mode = GET_MODE (XEXP (x, 1));
|
|
||||||
if (cmp_mode == VOIDmode)
|
|
||||||
cmp_mode = op0_mode;
|
|
||||||
}
|
|
||||||
temp = simplify_relational_operation (code, mode, cmp_mode,
|
|
||||||
XEXP (x, 0), XEXP (x, 1));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RTX_COMM_ARITH:
|
|
||||||
case RTX_BIN_ARITH:
|
|
||||||
temp = simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x, 1));
|
|
||||||
break;
|
|
||||||
case RTX_BITFIELD_OPS:
|
|
||||||
case RTX_TERNARY:
|
|
||||||
temp = simplify_ternary_operation (code, mode, op0_mode, XEXP (x, 0),
|
|
||||||
XEXP (x, 1), XEXP (x, 2));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (temp)
|
|
||||||
{
|
|
||||||
x = temp;
|
|
||||||
code = GET_CODE (temp);
|
|
||||||
op0_mode = VOIDmode;
|
|
||||||
mode = GET_MODE (temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First see if we can apply the inverse distributive law. */
|
/* First see if we can apply the inverse distributive law. */
|
||||||
if (code == PLUS || code == MINUS
|
if (code == PLUS || code == MINUS
|
||||||
|| code == AND || code == IOR || code == XOR)
|
|| code == AND || code == IOR || code == XOR)
|
||||||
|
|
Loading…
Reference in New Issue