Commit 9d317251 by Roger Sayle Committed by Roger Sayle

simplify-rtx.c (simplify_binary_operation): Constant fold DIV, MOD, UDIV and…

simplify-rtx.c (simplify_binary_operation): Constant fold DIV, MOD, UDIV and UMOD using div_and_round_double.


	* simplify-rtx.c (simplify_binary_operation): Constant fold
	DIV, MOD, UDIV and UMOD using div_and_round_double.

From-SVN: r80420
parent e1c6f28d
2004-04-04 Roger Sayle <roger@eyesopen.com>
* simplify-rtx.c (simplify_binary_operation): Constant fold
DIV, MOD, UDIV and UMOD using div_and_round_double.
2004-04-04 Mark Mitchell <mark@codesourcery.com> 2004-04-04 Mark Mitchell <mark@codesourcery.com>
PR c++/14804 PR c++/14804
......
...@@ -1285,8 +1285,8 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode, ...@@ -1285,8 +1285,8 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
&& (GET_CODE (trueop1) == CONST_DOUBLE && (GET_CODE (trueop1) == CONST_DOUBLE
|| GET_CODE (trueop1) == CONST_INT)) || GET_CODE (trueop1) == CONST_INT))
{ {
unsigned HOST_WIDE_INT l1, l2, lv; unsigned HOST_WIDE_INT l1, l2, lv, lt;
HOST_WIDE_INT h1, h2, hv; HOST_WIDE_INT h1, h2, hv, ht;
if (GET_CODE (trueop0) == CONST_DOUBLE) if (GET_CODE (trueop0) == CONST_DOUBLE)
l1 = CONST_DOUBLE_LOW (trueop0), h1 = CONST_DOUBLE_HIGH (trueop0); 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, ...@@ -1315,10 +1315,29 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
mul_double (l1, h1, l2, h2, &lv, &hv); mul_double (l1, h1, l2, h2, &lv, &hv);
break; break;
case DIV: case MOD: case UDIV: case UMOD: case DIV:
/* We'd need to include tree.h to do this and it doesn't seem worth if (div_and_round_double (TRUNC_DIV_EXPR, 0, l1, h1, l2, h2,
it. */ &lv, &hv, &lt, &ht))
return 0; 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: case AND:
lv = l1 & l2, hv = h1 & h2; lv = l1 & l2, hv = h1 & h2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment