summaryrefslogtreecommitdiffstats
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-05 03:14:13 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-05 03:14:13 +0000
commit2e746e59b1b2a9abdf5e9de5864d2b37ade8f38a (patch)
treee39b0fe41342b831b29e892e79e7c00796c0a51a /gcc/simplify-rtx.c
parentce1c7ada25340841a21a9596e9090651206d606e (diff)
downloadppe42-gcc-2e746e59b1b2a9abdf5e9de5864d2b37ade8f38a.tar.gz
ppe42-gcc-2e746e59b1b2a9abdf5e9de5864d2b37ade8f38a.zip
* simplify-rtx.c (simplify_binary_operation): Constant fold
DIV, MOD, UDIV and UMOD using div_and_round_double. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80420 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 0058589dc43..0d283cd2505 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -1285,8 +1285,8 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
&& (GET_CODE (trueop1) == CONST_DOUBLE
|| GET_CODE (trueop1) == CONST_INT))
{
- unsigned HOST_WIDE_INT l1, l2, lv;
- HOST_WIDE_INT h1, h2, hv;
+ unsigned HOST_WIDE_INT l1, l2, lv, lt;
+ HOST_WIDE_INT h1, h2, hv, ht;
if (GET_CODE (trueop0) == CONST_DOUBLE)
l1 = CONST_DOUBLE_LOW (trueop0), h1 = CONST_DOUBLE_HIGH (trueop0);
@@ -1315,10 +1315,29 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
mul_double (l1, h1, l2, h2, &lv, &hv);
break;
- case DIV: case MOD: case UDIV: case UMOD:
- /* We'd need to include tree.h to do this and it doesn't seem worth
- it. */
- return 0;
+ case DIV:
+ if (div_and_round_double (TRUNC_DIV_EXPR, 0, l1, h1, l2, h2,
+ &lv, &hv, &lt, &ht))
+ return 0;
+ break;
+
+ case MOD:
+ if (div_and_round_double (TRUNC_DIV_EXPR, 0, l1, h1, l2, h2,
+ &lt, &ht, &lv, &hv))
+ return 0;
+ break;
+
+ case UDIV:
+ if (div_and_round_double (TRUNC_DIV_EXPR, 1, l1, h1, l2, h2,
+ &lv, &hv, &lt, &ht))
+ return 0;
+ break;
+
+ case UMOD:
+ if (div_and_round_double (TRUNC_DIV_EXPR, 1, l1, h1, l2, h2,
+ &lt, &ht, &lv, &hv))
+ return 0;
+ break;
case AND:
lv = l1 & l2, hv = h1 & h2;
OpenPOWER on IntegriCloud