This is the mail archive of the
mailing list for the GCC project.
[PATCH] Handle MODE_CC in gen_lowpart_common (take 2)
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Geoff Keating <geoffk at geoffk dot org>
- Date: Sun, 1 Jun 2003 06:47:45 -0600 (MDT)
- Subject: [PATCH] Handle MODE_CC in gen_lowpart_common (take 2)
On 29 May 2003, Geoff Keating wrote:
> Roger Sayle <email@example.com> writes:
> > http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01757.html
> > Handle MODE_CC in gen_lowpart_common
> This is not OK, because MODE_CC values need not always be true
> or false, the point of MODE_CC is that sometimes there are many
> possible values and it's machine-defined what they mean.
My apologies for my previous misunderstandings. I'd previously
thought that you were opposed to this patch on the basis that
condition codes shouldn't be represented as integer constants.
The above review makes it much clearer that the real problem
with the previous patch was that it was ascribing a meaning
to those bits. I completely agree the middle-end shouldn't
enforce true/false semantics on MODE_CC values provided by the
backends, especially when not required. As Geoff has mentioned,
the PowerPC, for example, has a four-bit condition code register.
And as we've discussed before the only way an integer value
can appear in the source of a condition code setter, is if
the machine description is written to allow that to happen.
The following patch (which is a simplified version of the original)
has been tested on i686-pc-linux-gnu with a full "make bootstrap",
all languages except treelang, and regression checked with a top-level
"make -k check" with no new failures.
Ok for mainline?
2003-06-01 Roger Sayle <firstname.lastname@example.org>
John David Anglin <email@example.com>
Geoffrey Keating <firstname.lastname@example.org>
* emit-rtl.c (gen_lowpart_common): Handle interpreting integer
constants as condition code values.
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.327
diff -c -3 -p -r1.327 emit-rtl.c
*** emit-rtl.c 30 May 2003 21:41:21 -0000 1.327
--- emit-rtl.c 31 May 2003 17:30:25 -0000
*************** gen_lowpart_common (mode, x)
*** 1291,1296 ****
--- 1291,1302 ----
+ /* If MODE is a condition code and X is a CONST_INT, the value of X
+ must already have been "recognized" by the back-end, and we can
+ assume that it is valid for this mode. */
+ else if (GET_MODE_CLASS (mode) == MODE_CC
+ && GET_CODE (x) == CONST_INT)
+ return x;
/* Otherwise, we can't do this. */
Roger Sayle, E-mail: email@example.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