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]

genrecog fix


Hi
Genrecog can produce switch statements over HOST_WIDE_INT.
This breaks, if it is winder than integer, since the type is casted
to (int) for the switch (for compatibility with K&R).

On x86_64 this has showed as an regression where 0x100000000 was
mistakely recognized as 0 and blowed out.

I am simply disabling use of switches in case int is too short. Perhaps
someone want to come with more sensible solution.

I belive this patch may be candidate for the branch, but someone
needs to help me with constructing testcase.  Simply you need to find
host with 64bit long and 32bit int, find pattern that matches
by (const_int value) and genrecog generates switch statement and write
code to trigger pattern badly.

Sun May  6 01:16:10 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* genrecog.c (write_switch): Avoid outputting of switch for
	types wider than int.

*** genrecog.c.old	Sun May  6 01:07:14 2001
--- genrecog.c	Sun May  6 01:12:58 2001
*************** write_switch (start, depth)
*** 1860,1865 ****
--- 1860,1869 ----
  	   || type == DT_elt_one_int
  	   || type == DT_elt_zero_wide)
      {
+       /* The argument is casted to int.  In case HOST_WIDE_INT is more exact,
+          we can't safely construct switch statement over it.  */
+       if (type == DT_elt_zero_wide && HOST_BITS_PER_WIDE_INT > sizeof (int) * 8)
+ 	  return p;
        printf ("  switch (");
        switch (type)
  	{


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