This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Handle MODE_CC in gen_lowpart_common (take 2)

On 29 May 2003, Geoff Keating wrote:
> Roger Sayle <> writes:
> >
> > 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  <>
	    John David Anglin  <>
	    Geoffrey Keating  <>

	* 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.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.  */
    return 0;

Roger Sayle,                         E-mail:
OpenEye Scientific Software,         WWW:
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]