This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Tweak i386.md's movhi_1 and movqi_1 for -Os
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 18 Jan 2004 11:33:45 -0700 (MST)
- Subject: [PATCH] Tweak i386.md's movhi_1 and movqi_1 for -Os
Whilst investigating a code size PR, I noticed that the i386
backend doesn't consider optimize_size when deciding to use
"movzbl" and "movzwl" instead of the shorter "movb" and "movw"
instructions respectively. This was confusing my analysis as some
x86 boxes produce larger code with -Os, based upon their default
-mtune setting.
The following patch reduces CSiBE by about 1K when compiled with
"-Os -mtune=athlon".
The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all languages except Ada and treelang, and regression
tested with a top-level "make -k check" with no new failures.
Ok for mainline?
2004-01-18 Roger Sayle <roger@eyesopen.com>
* config/i386/i386.md (*movhi_1, *movqi_1): When optimizing for
size, don't use the larger zero-extending loads.
Index: config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.502
diff -c -3 -p -r1.502 i386.md
*** config/i386/i386.md 16 Jan 2004 18:53:45 -0000 1.502
--- config/i386/i386.md 18 Jan 2004 17:11:44 -0000
***************
*** 1297,1314 ****
(match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
"GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
{
! switch (get_attr_type (insn))
! {
! case TYPE_IMOVX:
! /* movzwl is faster than movw on p2 due to partial word stalls,
! though not as fast as an aligned movl. */
! return "movz{wl|x}\t{%1, %k0|%k0, %1}";
! default:
! if (get_attr_mode (insn) == MODE_SI)
! return "mov{l}\t{%k1, %k0|%k0, %k1}";
! else
! return "mov{w}\t{%1, %0|%0, %1}";
! }
}
[(set (attr "type")
(cond [(and (eq_attr "alternative" "0")
--- 1297,1311 ----
(match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
"GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
{
! if (! optimize_size && get_attr_type (insn) == TYPE_IMOVX)
! /* movzwl is faster than movw on p2 due to partial word stalls,
! though not as fast as an aligned movl. */
! return "movz{wl|x}\t{%1, %k0|%k0, %1}";
!
! if (get_attr_mode (insn) == MODE_SI)
! return "mov{l}\t{%k1, %k0|%k0, %k1}";
! else
! return "mov{w}\t{%1, %0|%0, %1}";
}
[(set (attr "type")
(cond [(and (eq_attr "alternative" "0")
***************
*** 1472,1489 ****
(match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
"GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
{
! switch (get_attr_type (insn))
{
- case TYPE_IMOVX:
if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
abort ();
return "movz{bl|x}\t{%1, %k0|%k0, %1}";
- default:
- if (get_attr_mode (insn) == MODE_SI)
- return "mov{l}\t{%k1, %k0|%k0, %k1}";
- else
- return "mov{b}\t{%1, %0|%0, %1}";
}
}
[(set (attr "type")
(cond [(and (eq_attr "alternative" "3")
--- 1469,1484 ----
(match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
"GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
{
! if (! optimize_size && get_attr_type (insn) == TYPE_IMOVX)
{
if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
abort ();
return "movz{bl|x}\t{%1, %k0|%k0, %1}";
}
+ if (get_attr_mode (insn) == MODE_SI)
+ return "mov{l}\t{%k1, %k0|%k0, %k1}";
+ else
+ return "mov{b}\t{%1, %0|%0, %1}";
}
[(set (attr "type")
(cond [(and (eq_attr "alternative" "3")
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833