[PATCH] combine: Fix subst_low_luid setting - bootstrap failure on s390x

Andreas Krebbel krebbel@linux.vnet.ibm.com
Mon Sep 6 14:24:00 GMT 2010


Hi,

the attached patches fixes a misoptimization in combine.  Due to a
wrong setting of the subst_low_luid field a wrong nonzero mask has
been used what led to a miscompilation of genpreds on s390x.  Probably
a simple copy and paste bug.

Fixed with the attached patch.

Bootstrapped on s390x.

Bye,

-Andreas-


2010-09-06  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* combine.c (try_combine): Set subst_low_luid to i0.

2010-09-06  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* gcc.dg/20100906-1.c: New testcase.

Index: gcc/combine.c
===================================================================
*** gcc/combine.c.orig
--- gcc/combine.c
*************** try_combine (rtx i3, rtx i2, rtx i1, rtx
*** 3138,3144 ****
  	}
  
        n_occurrences = 0;
!       subst_low_luid = DF_INSN_LUID (i1);
        newpat = subst (newpat, i0dest, i0src, 0,
  		      i0_feeds_i1_n && i0dest_in_i0src);
        substed_i0 = 1;
--- 3138,3144 ----
  	}
  
        n_occurrences = 0;
!       subst_low_luid = DF_INSN_LUID (i0);
        newpat = subst (newpat, i0dest, i0src, 0,
  		      i0_feeds_i1_n && i0dest_in_i0src);
        substed_i0 = 1;
Index: gcc/testsuite/gcc.dg/20100906-1.c
===================================================================
*** /dev/null
--- gcc/testsuite/gcc.dg/20100906-1.c
***************
*** 0 ****
--- 1,48 ----
+ /* { dg-do run } */
+ /* { dg-options "-O2" } */
+ 
+ /* This testcase got misoptimized by combine due to a wrong setting of
+    subst_low_luid in try_combine.  */
+ 
+ enum rtx_code {
+   A, B
+ };
+ 
+ void abort (void);
+ 
+ struct rtx_def {
+   __extension__ enum rtx_code code:16;
+ };
+ typedef struct rtx_def *rtx;
+ 
+ void __attribute__((noinline))
+ add_constraint (unsigned char is_a)
+ {
+   if (is_a)
+     abort ();
+ }
+ 
+ void __attribute__((noinline))
+ foo (rtx defn)
+ {
+   switch (defn->code)
+     {
+     case A:
+     case B:
+       add_constraint (defn->code == A);
+       break;
+     default:
+       break;
+     }
+ }
+ 
+ int
+ main ()
+ {
+   struct rtx_def r;
+ 
+   r.code = B;
+ 
+   foo (&r);
+   return 0;
+ }



More information about the Gcc-patches mailing list