PATCH: Remove SLOW_BYTE_ACCESS from get_best_mode
H. J. Lu
hjl@lucon.org
Sun Sep 10 17:57:00 GMT 2006
On Fri, Sep 08, 2006 at 11:52:51PM -0700, H. J. Lu wrote:
> Why do we use SLOW_BYTE_ACCESS to control bit field access? Bit field
> currently is implemented as unsigned int, at least for x86. Accessing
> bit field as 32bit is always faster unless 4 byte accesses are
> much faster one 32bit access, which is very unlikely will be true for
> x86 in any circumstances. Is this a leftover from the old bit field
> implementation?
>
I don't understand why we use byte instruction to access 32bit field.
There may be some hardwares where 4 byte accesses are faster than one
32bit access. But I am not aware any x86 one. I tried this patch on
Prescott, Nocona, Core and Core 2. There are no regressions in gcc
testsuites nor negative performance impact on SPEC CPU 2K.
H.J.
-----
2006-09-10 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.h (FAST_BYTE_ACCESS_BITFIELD): New.
* stor-layout.c (FAST_BYTE_ACCESS_BITFIELD): New. Defined with
SLOW_BYTE_ACCESS if not defined.
(get_best_mode): Check FAST_BYTE_ACCESS_BITFIELD instead of
SLOW_BYTE_ACCESS.
--- gcc/config/i386/i386.h.slow 2006-09-08 17:55:37.000000000 -0700
+++ gcc/config/i386/i386.h 2006-09-09 06:44:55.000000000 -0700
@@ -1844,6 +1844,8 @@ do { \
#define SLOW_BYTE_ACCESS 0
+#define FAST_BYTE_ACCESS_BITFIELD 0
+
/* Nonzero if access to memory by shorts is slow and undesirable. */
#define SLOW_SHORT_ACCESS 0
--- gcc/stor-layout.c.slow 2006-09-07 11:13:09.000000000 -0700
+++ gcc/stor-layout.c 2006-09-09 06:48:07.000000000 -0700
@@ -2113,16 +2113,20 @@ fixup_unsigned_type (tree type)
If no mode meets all these conditions, we return VOIDmode.
- If VOLATILEP is false and SLOW_BYTE_ACCESS is false, we return the
+ If VOLATILEP is false and FAST_BYTE_ACCESS_BITFIELD is true, we return the
smallest mode meeting these conditions.
- If VOLATILEP is false and SLOW_BYTE_ACCESS is true, we return the
+ If VOLATILEP is false and FAST_BYTE_ACCESS_BITFIELD is false, we return the
largest mode (but a mode no wider than UNITS_PER_WORD) that meets
all the conditions.
If VOLATILEP is true the narrow_volatile_bitfields target hook is used to
decide which of the above modes should be used. */
+#ifndef FAST_BYTE_ACCESS_BITFIELD
+#define FAST_BYTE_ACCESS_BITFIELD (!SLOW_BYTE_ACCESS)
+#endif
+
enum machine_mode
get_best_mode (int bitsize, int bitpos, unsigned int align,
enum machine_mode largest_mode, int volatilep)
@@ -2151,7 +2155,7 @@ get_best_mode (int bitsize, int bitpos,
|| (largest_mode != VOIDmode && unit > GET_MODE_BITSIZE (largest_mode)))
return VOIDmode;
- if ((SLOW_BYTE_ACCESS && ! volatilep)
+ if ((! FAST_BYTE_ACCESS_BITFIELD && ! volatilep)
|| (volatilep && !targetm.narrow_volatile_bitfield()))
{
enum machine_mode wide_mode = VOIDmode, tmode;
More information about the Gcc-patches
mailing list