This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Handle MODE_CC in gen_lowpart_common
- From: Roger Sayle <roger at www dot eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 22 Apr 2003 20:29:04 -0600 (MDT)
- Subject: [PATCH]: Handle MODE_CC in gen_lowpart_common
Dave Anglin recently wrote:
> 2) The CSE pass can't simplify conditional jumps involving
> CC_MODE registers because gen_lowpart_common doesn't handle
> CC_MODE. As a result, the state of a CC_MODE register doesn't
> get recorded and the if_then_else can't be simplified.
The patch below addresses this deficiency allowing gen_lowpart_common
to interpret integer constants as CC_MODE values. This allows CSE to
simplify the code example given in PR optimization/8705 on PA-Risc.
The following patch has been tested on both i686-pc-linux-gnu and
hppa2.0w-hp-hpux11.00 with a full "make bootstrap", all languages
except Ada and treelang, and regression checked with a top-level
"make -k check" with no new failures on either platform.
Ok for mainline?
2003-04-22 Roger Sayle <roger at eyesopen dot com>
John David Anglin <dave dot anglin at nrc-cnrc dot gc dot ca>
* emit-rtl.c (gen_lowpart_common): Handle interpreting integer
constants as condition code values.
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.323
diff -c -3 -p -r1.323 emit-rtl.c
*** emit-rtl.c 17 Apr 2003 23:31:40 -0000 1.323
--- emit-rtl.c 22 Apr 2003 16:14:42 -0000
*************** gen_lowpart_common (mode, x)
*** 1290,1295 ****
--- 1290,1303 ----
mode);
#endif
}
+ /* If X is a CONST_INT or a CONST_DOUBLE, and MODE is a condition code
+ convert the constant into either const0_rtx or const_true_rtx. */
+ else if (GET_MODE_CLASS (mode) == MODE_CC
+ && GET_MODE (x) == VOIDmode
+ && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE))
+ {
+ return x == const0_rtx ? const0_rtx : const_true_rtx;
+ }
/* Otherwise, we can't do this. */
return 0;
Roger
--
Roger Sayle, E-mail: roger at eyesopen dot 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