aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-05-23 18:06:22 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-05-23 18:06:22 +0000
commit3839069b02cfe7fdec691f6aacb9fd01b21d61c3 (patch)
treed74eeea151683cddca3288fc1c7051594936223e
parentf31e826ba314bc910beec6de5bf534f2462a00c7 (diff)
downloadgcc-3839069b02cfe7fdec691f6aacb9fd01b21d61c3.zip
gcc-3839069b02cfe7fdec691f6aacb9fd01b21d61c3.tar.gz
gcc-3839069b02cfe7fdec691f6aacb9fd01b21d61c3.tar.bz2
simplify-rtx.c (SIGN_EXTEND): New macro.
* simplify-rtx.c (SIGN_EXTEND): New macro. (simplify_unary_operation, simplify_binary_operation, simplify_relational_operation): Use SIGN_EXTEND. Make low halves of (low, high) pairs unsigned if they weren't already. (simplify_ternary_operation): Cast INTVAL to unsigned before comparing to a MODE_BITSIZE. From-SVN: r34109
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/simplify-rtx.c35
2 files changed, 31 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a38bfeb..54b7927 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2000-05-23 Zack Weinberg <zack@wolery.cumb.org>
+
+ * simplify-rtx.c (SIGN_EXTEND): New macro.
+ (simplify_unary_operation, simplify_binary_operation,
+ simplify_relational_operation): Use SIGN_EXTEND. Make low
+ halves of (low, high) pairs unsigned if they weren't already.
+ (simplify_ternary_operation): Cast INTVAL to unsigned before
+ comparing to a MODE_BITSIZE.
+
2000-05-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4 (gcc_AC_CHECK_DECL, gcc_AC_CHECK_DECLS): New macros
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 270371c..88d02c1 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -92,6 +92,12 @@ Boston, MA 02111-1307, USA. */
|| XEXP (X, 0) == virtual_outgoing_args_rtx)) \
|| GET_CODE (X) == ADDRESSOF)
+/* Much code operates on (low, high) pairs; the low value is an
+ unsigned wide int, the high value a signed wide int. We
+ occasionally need to sign extend from low to high as if low were a
+ signed wide int. */
+#define SIGN_EXTEND(low) \
+ ((((HOST_WIDE_INT) low) < 0) ? ((HOST_WIDE_INT) -1) : ((HOST_WIDE_INT) 0))
static rtx simplify_plus_minus PARAMS ((enum rtx_code,
enum machine_mode, rtx, rtx));
@@ -246,7 +252,7 @@ simplify_unary_operation (code, mode, op, op_mode)
REAL_VALUE_TYPE d;
if (GET_CODE (op) == CONST_INT)
- lv = INTVAL (op), hv = INTVAL (op) < 0 ? -1 : 0;
+ lv = INTVAL (op), hv = SIGN_EXTEND (lv);
else
lv = CONST_DOUBLE_LOW (op), hv = CONST_DOUBLE_HIGH (op);
@@ -279,7 +285,7 @@ simplify_unary_operation (code, mode, op, op_mode)
REAL_VALUE_TYPE d;
if (GET_CODE (op) == CONST_INT)
- lv = INTVAL (op), hv = INTVAL (op) < 0 ? -1 : 0;
+ lv = INTVAL (op), hv = SIGN_EXTEND (lv);
else
lv = CONST_DOUBLE_LOW (op), hv = CONST_DOUBLE_HIGH (op);
@@ -399,12 +405,13 @@ simplify_unary_operation (code, mode, op, op_mode)
else if (GET_MODE (op) == VOIDmode && width <= HOST_BITS_PER_INT * 2
&& (GET_CODE (op) == CONST_DOUBLE || GET_CODE (op) == CONST_INT))
{
- HOST_WIDE_INT l1, h1, lv, hv;
+ unsigned HOST_WIDE_INT l1, lv;
+ HOST_WIDE_INT h1, hv;
if (GET_CODE (op) == CONST_DOUBLE)
l1 = CONST_DOUBLE_LOW (op), h1 = CONST_DOUBLE_HIGH (op);
else
- l1 = INTVAL (op), h1 = l1 < 0 ? -1 : 0;
+ l1 = INTVAL (op), h1 = SIGN_EXTEND (l1);
switch (code)
{
@@ -458,7 +465,7 @@ simplify_unary_operation (code, mode, op, op_mode)
<< (GET_MODE_BITSIZE (op_mode) - 1))) != 0)
lv -= (HOST_WIDE_INT) 1 << GET_MODE_BITSIZE (op_mode);
- hv = (lv < 0) ? ~ (HOST_WIDE_INT) 0 : 0;
+ hv = SIGN_EXTEND (lv);
}
break;
@@ -709,17 +716,18 @@ simplify_binary_operation (code, mode, op0, op1)
&& (GET_CODE (op0) == CONST_DOUBLE || GET_CODE (op0) == CONST_INT)
&& (GET_CODE (op1) == CONST_DOUBLE || GET_CODE (op1) == CONST_INT))
{
- HOST_WIDE_INT l1, l2, h1, h2, lv, hv;
+ unsigned HOST_WIDE_INT l1, l2, lv;
+ HOST_WIDE_INT h1, h2, hv;
if (GET_CODE (op0) == CONST_DOUBLE)
l1 = CONST_DOUBLE_LOW (op0), h1 = CONST_DOUBLE_HIGH (op0);
else
- l1 = INTVAL (op0), h1 = l1 < 0 ? -1 : 0;
+ l1 = INTVAL (op0), h1 = SIGN_EXTEND (l1);
if (GET_CODE (op1) == CONST_DOUBLE)
l2 = CONST_DOUBLE_LOW (op1), h2 = CONST_DOUBLE_HIGH (op1);
else
- l2 = INTVAL (op1), h2 = l2 < 0 ? -1 : 0;
+ l2 = INTVAL (op1), h2 = SIGN_EXTEND (l2);
switch (code)
{
@@ -803,7 +811,7 @@ simplify_binary_operation (code, mode, op0, op1)
l2 &= (GET_MODE_BITSIZE (mode) - 1), h2 = 0;
#endif
- if (h2 != 0 || l2 < 0 || l2 >= GET_MODE_BITSIZE (mode))
+ if (h2 != 0 || l2 >= GET_MODE_BITSIZE (mode))
return 0;
if (code == LSHIFTRT || code == ASHIFTRT)
@@ -1752,7 +1760,7 @@ simplify_relational_operation (code, mode, op0, op1)
else
{
l0u = l0s = INTVAL (op0);
- h0u = h0s = l0s < 0 ? -1 : 0;
+ h0u = h0s = SIGN_EXTEND (l0s);
}
if (GET_CODE (op1) == CONST_DOUBLE)
@@ -1763,13 +1771,13 @@ simplify_relational_operation (code, mode, op0, op1)
else
{
l1u = l1s = INTVAL (op1);
- h1u = h1s = l1s < 0 ? -1 : 0;
+ h1u = h1s = SIGN_EXTEND (l1s);
}
/* If WIDTH is nonzero and smaller than HOST_BITS_PER_WIDE_INT,
we have to sign or zero-extend the values. */
if (width != 0 && width <= HOST_BITS_PER_WIDE_INT)
- h0u = h1u = 0, h0s = l0s < 0 ? -1 : 0, h1s = l1s < 0 ? -1 : 0;
+ h0u = h1u = 0, h0s = SIGN_EXTEND (l0s), h1s = SIGN_EXTEND (l1s);
if (width != 0 && width < HOST_BITS_PER_WIDE_INT)
{
@@ -1904,7 +1912,8 @@ simplify_ternary_operation (code, mode, op0_mode, op0, op1, op2)
if (GET_CODE (op0) == CONST_INT
&& GET_CODE (op1) == CONST_INT
&& GET_CODE (op2) == CONST_INT
- && INTVAL (op1) + INTVAL (op2) <= GET_MODE_BITSIZE (op0_mode)
+ && ((unsigned) INTVAL (op1) + (unsigned) INTVAL (op2)
+ <= GET_MODE_BITSIZE (op0_mode))
&& width <= (unsigned) HOST_BITS_PER_WIDE_INT)
{
/* Extracting a bit-field from a constant */