This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix CONST_DOUBLE usage
- From: "David S. Miller" <davem at davemloft dot net>
- To: gcc-patches at gcc dot gnu dot org
- Cc: ebotcazou at libertysurf dot fr
- Date: Fri, 22 Apr 2005 17:29:39 -0700
- Subject: [PATCH] Fix CONST_DOUBLE usage
Eric B. noticed that Sparc'c sparc_rtx_costs() was testing
incorrectly whether a CONST_DOUBLE is representing an integer.
It should test against VOIDmode not DImode.
It was also accessing the low/high parts incorrectly. I fixed
it to properly use CONST_DOUBLE_LOW and CONST_DOUBLE_HIGH.
When fixing that, I scanned all of the top-level compiler sources
for CONST_DOUBLE usage and noticed that sched-vis.c has the same bug
so fixed it there as well.
Though the documentation and many spots are correct on the
VOIDmode matter, rtl.h explicitly states "DImode" in a comment
above the CONST_DOUBLE_HIGH and CONST_DOUBLE_LOW definitions.
This seems to be a vestige from ancient times and would explain
why some DImode tests would still be lying around even today.
Should I fix up that rtl.h comment too? :-)
Committed to mainline.
2005-04-22 David S. Miller <davem@davemloft.net>
* sched-vis.c (print_value): Use CONST_DOUBLE_LOW and
CONST_DOUBLE_HIGH.
* config/sparc/sparc.c (sparc_rtx_costs): Likewise, and
fix check on CONST_DOUBLE mode. It should be VOIDmode
when it is representing an integer.
--- sched-vis.c 9 Sep 2004 17:19:13 -0000 1.33
+++ sched-vis.c 23 Apr 2005 00:28:22 -0000
@@ -435,7 +435,7 @@ print_value (char *buf, rtx x, int verbo
if (FLOAT_MODE_P (GET_MODE (x)))
real_to_decimal (t, CONST_DOUBLE_REAL_VALUE (x), sizeof (t), 0, 1);
else
- sprintf (t, "<0x%lx,0x%lx>", (long) XWINT (x, 2), (long) XWINT (x, 3));
+ sprintf (t, "<0x%lx,0x%lx>", (long) CONST_DOUBLE_LOW (x), (long) CONST_DOUBLE_HIGH (x));
cur = safe_concat (buf, cur, t);
break;
case CONST_STRING:
--- config/sparc/sparc.c 21 Apr 2005 06:37:48 -0000 1.365
+++ config/sparc/sparc.c 23 Apr 2005 00:28:23 -0000
@@ -7897,12 +7897,12 @@ sparc_rtx_costs (rtx x, int code, int ou
return true;
case CONST_DOUBLE:
- if (GET_MODE (x) == DImode
- && ((XINT (x, 3) == 0
- && (unsigned HOST_WIDE_INT) XINT (x, 2) < 0x1000)
- || (XINT (x, 3) == -1
- && XINT (x, 2) < 0
- && XINT (x, 2) >= -0x1000)))
+ if (GET_MODE (x) == VOIDmode
+ && ((CONST_DOUBLE_HIGH (x) == 0
+ && CONST_DOUBLE_LOW (x) < 0x1000)
+ || (CONST_DOUBLE_HIGH (x) == -1
+ && CONST_DOUBLE_LOW (x) < 0
+ && CONST_DOUBLE_LOW (x) >= -0x1000)))
*total = 0;
else
*total = 8;
@@ -7960,11 +7960,11 @@ sparc_rtx_costs (rtx x, int code, int ou
nbits++;
}
else if (GET_CODE (XEXP (x, 1)) == CONST_DOUBLE
- && GET_MODE (XEXP (x, 1)) == DImode)
+ && GET_MODE (XEXP (x, 1)) == VOIDmode)
{
rtx x1 = XEXP (x, 1);
- unsigned HOST_WIDE_INT value1 = XINT (x1, 2);
- unsigned HOST_WIDE_INT value2 = XINT (x1, 3);
+ unsigned HOST_WIDE_INT value1 = CONST_DOUBLE_LOW (x1);
+ unsigned HOST_WIDE_INT value2 = CONST_DOUBLE_HIGH (x1);
for (nbits = 0; value1 != 0; value1 &= value1 - 1)
nbits++;