This is the mail archive of the gcc-patches@gcc.gnu.org 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 <roger@eyesopen.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  <roger@eyesopen.com>
	    John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
	    Geoffrey Keating  <geoffk@apple.com>

	* 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 ----
  				 mode);
  #endif
      }
+   /* 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
--
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


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