Patchwork patch to fix PR55150

login
register
mail settings
Submitter Vladimir Makarov
Date Nov. 1, 2012, 6:58 p.m.
Message ID <5092C639.8070605@redhat.com>
Download mbox | patch
Permalink /patch/196333/
State New
Headers show

Comments

Vladimir Makarov - Nov. 1, 2012, 6:58 p.m.
The following patch fixes the second test of PR55150

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55150

   The patch was successfully bootstrapped on x86/x86-64.

   Committed as rev. 193065.

2012-11-01  Vladimir Makarov  <vmakarov@redhat.com>

     PR middle-end/55150
     * lra-constraints.c (lra_constraints): Check only pseudos with
     equivalences.  Add insns with equivalence pseudos.

2012-11-01  Vladimir Makarov  <vmakarov@redhat.com>

     PR middle-end/55150
     * gcc.dg/pr55150.c: Rename to gcc.dg/pr55150-1.c.
     * gcc.dg/pr55150-2.c: New test.

Patch

Index: lra-constraints.c
===================================================================
--- lra-constraints.c	(revision 193064)
+++ lra-constraints.c	(working copy)
@@ -3244,9 +3244,11 @@  lra_constraints (bool first_p)
 {
   bool changed_p;
   int i, hard_regno, new_insns_num;
-  unsigned int min_len, new_min_len;
-  rtx set, x, dest_reg;
+  unsigned int min_len, new_min_len, uid;
+  rtx set, x, reg, dest_reg;
   basic_block last_bb;
+  bitmap_head equiv_insn_bitmap;
+  bitmap_iterator bi;
 
   lra_constraint_iter++;
   if (lra_dump_file != NULL)
@@ -3261,10 +3263,12 @@  lra_constraints (bool first_p)
   lra_risky_transformations_p = false;
   new_insn_uid_start = get_max_uid ();
   new_regno_start = first_p ? lra_constraint_new_regno_start : max_reg_num ();
+  bitmap_initialize (&equiv_insn_bitmap, &reg_obstack);
   for (i = FIRST_PSEUDO_REGISTER; i < new_regno_start; i++)
     if (lra_reg_info[i].nrefs != 0)
       {
 	ira_reg_equiv[i].profitable_p = true;
+	reg = regno_reg_rtx[i];
 	if ((hard_regno = lra_get_regno_hard_regno (i)) >= 0)
 	  {
 	    int j, nregs = hard_regno_nregs[hard_regno][PSEUDO_REGNO_MODE (i)];
@@ -3272,7 +3276,7 @@  lra_constraints (bool first_p)
 	    for (j = 0; j < nregs; j++)
 	      df_set_regs_ever_live (hard_regno + j, true);
 	  }
-	else if ((x = get_equiv_substitution (regno_reg_rtx[i])) != NULL_RTX)
+	else if ((x = get_equiv_substitution (reg)) != reg)
 	  {
 	    bool pseudo_p = contains_reg_p (x, false, false);
 	    rtx set, insn;
@@ -3310,8 +3314,15 @@  lra_constraints (bool first_p)
 	      ira_reg_equiv[i].defined_p = false;
 	    if (contains_reg_p (x, false, true))
 	      ira_reg_equiv[i].profitable_p = false;
+	    if (get_equiv_substitution (reg) != reg)
+	      bitmap_ior_into (&equiv_insn_bitmap, &lra_reg_info[i].insn_bitmap);
 	  }
       }
+  /* We should add all insns containing pseudos which should be
+     substituted by their equivalences.  */
+  EXECUTE_IF_SET_IN_BITMAP (&equiv_insn_bitmap, 0, uid, bi)
+    lra_push_insn_by_uid (uid);
+  bitmap_clear (&equiv_insn_bitmap);
   lra_eliminate (false);
   min_len = lra_insn_stack_length ();
   new_insns_num = 0;
Index: testsuite/gcc.dg/pr55150-1.c
===================================================================
--- testsuite/gcc.dg/pr55150-1.c	(revision 0)
+++ testsuite/gcc.dg/pr55150-1.c	(working copy)
@@ -0,0 +1,72 @@ 
+/* PR middle-end/55150 */
+/* { dg-do compile } */
+/* { dg-options "-Os -g" } */
+
+typedef unsigned int KEY_TABLE_TYPE[(272 / 4)];
+  typedef unsigned int u32;
+  typedef unsigned char u8;
+  static const u32 Camellia_SBOX[][256] = {
+  };
+   static const u32 SIGMA[] = {
+    0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, 0xc6ef372f, 0xe94f82be,     0x54ff53a5, 0xf1d36f1c, 0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd };
+   int Camellia_Ekeygen (int keyBitLength, const u8 * rawKey, KEY_TABLE_TYPE k) {
+    register u32 s0, s1, s2, s3;
+    k[0] = s0 = (    	 {
+    	 u32 r = *(const u32 *) (rawKey);
+  r;
+ }
+    );
+    k[2] = s2 = (		{
+    	 u32 r = *(const u32 *) (rawKey + 8);
+  r;
+ }
+    );
+    k[3] = s3 = (		{
+    	 u32 r = *(const u32 *) (rawKey + 12);
+  r;
+ }
+    );
+    if (keyBitLength != 128)     {
+        k[8] = s0 = ( 		     {
+  	         u32 r = *(const u32 *) (rawKey + 16);
+  r;
+ }
+        );
+        if (keyBitLength == 192)	{
+  	  k[10] = s2 = ~s0;
+  	    k[11] = s3 = ~s1;
+  	    }
+      }
+    s0 ^= k[0], s1 ^= k[1], s2 ^= k[2], s3 ^= k[3];
+    if (keyBitLength == 128)     {
+        k[4] = s0, k[5] = s1, k[6] = s2, k[7] = s3;
+      }
+    else     {
+        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;
+        s0 ^= k[8], s1 ^= k[9], s2 ^= k[10], s3 ^= k[11];
+        do    {
+  	  register u32 _t0, _t1, _t2, _t3;
+  	    _t0 = s2 ^ ((SIGMA + 10))[0];
+  	      _t3 ^= Camellia_SBOX[3][(_t0 >> 8) & 0xff];
+  	        s1 ^= _t3;
+  		}
+        while (0);
+        do    {
+  	  u32 _t0 = s0 >> (32 - 30);
+  	    s2 = (s2 << 30) | (s3 >> (32 - 30));
+  	      s3 = (s3 << 30) | _t0;
+  	      }
+        while (0);
+        k[40] = s0, k[41] = s1, k[42] = s2, k[43] = s3;
+        k[64] = s1, k[65] = s2, k[66] = s3, k[67] = s0;
+        s0 = k[8], s1 = k[9], s2 = k[10], s3 = k[11];
+        k[36] = s0, k[37] = s1, k[38] = s2, k[39] = s3;
+        s0 = k[12], s1 = k[13], s2 = k[14], s3 = k[15];
+        do   {
+  	  s1 = (s1 << 15) | (s2 >> (32 - 15));
+  	  }
+        while (0);
+        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;
+        k[44] = s1, k[45] = s2, k[46] = s3, k[47] = s0;
+      }
+  }
Index: testsuite/gcc.dg/pr55150-2.c
===================================================================
--- testsuite/gcc.dg/pr55150-2.c	(revision 0)
+++ testsuite/gcc.dg/pr55150-2.c	(working copy)
@@ -0,0 +1,53 @@ 
+/* PR middle-end/55150 */
+/* { dg-do compile } */
+/* { dg-options "-Os -g -fPIC" } */
+
+typedef unsigned char DES_cblock[8];
+ typedef struct DES_ks {
+ }
+ DES_key_schedule;
+ void DES_ede3_cbcm_encrypt (const unsigned char *in, unsigned char *out, 		       long length, DES_key_schedule * ks1, 		       DES_key_schedule * ks2, DES_key_schedule * ks3, 		       DES_cblock * ivec1, DES_cblock * ivec2, int enc) {
+   register unsigned long tout0, tout1, xor0, xor1, m0, m1;
+   register long l = length;
+   unsigned long tin[2];
+   unsigned char *iv1, *iv2;
+   iv1 = &(*ivec1)[0];
+   iv2 = &(*ivec2)[0];
+   if (enc)     {
+       (m0 = ((unsigned long) (*((iv1)++))), m0 |=        ((unsigned long) (*((iv1)++))) << 8L, m0 |=        ((unsigned long) (*((iv1)++))) << 16L, m0 |=        ((unsigned long) (*((iv1)++))) << 24L);
+       (m1 = ((unsigned long) (*((iv1)++))), m1 |=        ((unsigned long) (*((iv1)++))) << 8L, m1 |=        ((unsigned long) (*((iv1)++))) << 16L, m1 |=        ((unsigned long) (*((iv1)++))) << 24L);
+       (tout0 = ((unsigned long) (*((iv2)++))), tout0 |=        ((unsigned long) (*((iv2)++))) << 8L, tout0 |=        ((unsigned long) (*((iv2)++))) << 16L, tout0 |=        ((unsigned long) (*((iv2)++))) << 24L);
+       for (l -= 8;
+ l >= -7;
+ l -= 8) 	{
+ 	  DES_encrypt1 (tin, ks3, 1);
+ 	  DES_encrypt1 (tin, ks1, 1);
+ 	}
+       (*((iv1)++) = (unsigned char) (((m0)) & 0xff), *((iv1)++) =        (unsigned char) (((m0) >> 8L) & 0xff), *((iv1)++) =        (unsigned char) (((m0) >> 16L) & 0xff), *((iv1)++) =        (unsigned char) (((m0) >> 24L) & 0xff));
+       (*((iv1)++) = (unsigned char) (((m1)) & 0xff), *((iv1)++) =        (unsigned char) (((m1) >> 8L) & 0xff), *((iv1)++) =        (unsigned char) (((m1) >> 16L) & 0xff), *((iv1)++) =        (unsigned char) (((m1) >> 24L) & 0xff));
+       (*((iv2)++) = (unsigned char) (((tout0)) & 0xff), *((iv2)++) =        (unsigned char) (((tout0) >> 8L) & 0xff), *((iv2)++) =        (unsigned char) (((tout0) >> 16L) & 0xff), *((iv2)++) =        (unsigned char) (((tout0) >> 24L) & 0xff));
+     }
+   else     {
+       (m0 = ((unsigned long) (*((iv1)++))), m0 |=        ((unsigned long) (*((iv1)++))) << 8L, m0 |=        ((unsigned long) (*((iv1)++))) << 16L, m0 |=        ((unsigned long) (*((iv1)++))) << 24L);
+       (xor1 = ((unsigned long) (*((iv2)++))), xor1 |=        ((unsigned long) (*((iv2)++))) << 8L, xor1 |=        ((unsigned long) (*((iv2)++))) << 16L, xor1 |=        ((unsigned long) (*((iv2)++))) << 24L);
+       for (l -= 8;
+ l >= -7;
+ l -= 8) 	{
+ 	  DES_encrypt1 (tin, ks3, 1);
+ 	  if (l < 0) 	    {
+ 	      {
+ 		switch (l + 8) 		  {
+ 		  case 7: 		    *(--(out)) = (unsigned char) (((tout1) >> 16L) & 0xff);
+ 		  case 6: 		    *(--(out)) = (unsigned char) (((tout1) >> 8L) & 0xff);
+ 		  case 5: 		    *(--(out)) = (unsigned char) (((tout1)) & 0xff);
+ 		  case 4: 		    *(--(out)) = (unsigned char) (((tout0) >> 24L) & 0xff);
+ 		  case 1: 		    *(--(out)) = (unsigned char) (((tout0)) & 0xff);
+ 		  }
+ 	      };
+ 	    }
+ 	}
+       (*((iv1)++) = (unsigned char) (((m0)) & 0xff), *((iv1)++) =        (unsigned char) (((m0) >> 8L) & 0xff), *((iv1)++) =        (unsigned char) (((m0) >> 16L) & 0xff), *((iv1)++) =        (unsigned char) (((m0) >> 24L) & 0xff));
+       (*((iv2)++) = (unsigned char) (((xor0)) & 0xff), *((iv2)++) =        (unsigned char) (((xor0) >> 8L) & 0xff), *((iv2)++) =        (unsigned char) (((xor0) >> 16L) & 0xff), *((iv2)++) =        (unsigned char) (((xor0) >> 24L) & 0xff));
+       (*((iv2)++) = (unsigned char) (((xor1)) & 0xff), *((iv2)++) =        (unsigned char) (((xor1) >> 8L) & 0xff), *((iv2)++) =        (unsigned char) (((xor1) >> 16L) & 0xff), *((iv2)++) =        (unsigned char) (((xor1) >> 24L) & 0xff));
+     }
+ }
Index: testsuite/gcc.dg/pr55150.c
===================================================================
--- testsuite/gcc.dg/pr55150.c	(revision 193064)
+++ testsuite/gcc.dg/pr55150.c	(working copy)
@@ -1,72 +0,0 @@ 
-/* PR middle-end/55150 */
-/* { dg-do compile } */
-/* { dg-options "-Os -g" } */
-
-typedef unsigned int KEY_TABLE_TYPE[(272 / 4)];
-  typedef unsigned int u32;
-  typedef unsigned char u8;
-  static const u32 Camellia_SBOX[][256] = {
-  };
-   static const u32 SIGMA[] = {
-    0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, 0xc6ef372f, 0xe94f82be,     0x54ff53a5, 0xf1d36f1c, 0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd };
-   int Camellia_Ekeygen (int keyBitLength, const u8 * rawKey, KEY_TABLE_TYPE k) {
-    register u32 s0, s1, s2, s3;
-    k[0] = s0 = (    	 {
-    	 u32 r = *(const u32 *) (rawKey);
-  r;
- }
-    );
-    k[2] = s2 = (		{
-    	 u32 r = *(const u32 *) (rawKey + 8);
-  r;
- }
-    );
-    k[3] = s3 = (		{
-    	 u32 r = *(const u32 *) (rawKey + 12);
-  r;
- }
-    );
-    if (keyBitLength != 128)     {
-        k[8] = s0 = ( 		     {
-  	         u32 r = *(const u32 *) (rawKey + 16);
-  r;
- }
-        );
-        if (keyBitLength == 192)	{
-  	  k[10] = s2 = ~s0;
-  	    k[11] = s3 = ~s1;
-  	    }
-      }
-    s0 ^= k[0], s1 ^= k[1], s2 ^= k[2], s3 ^= k[3];
-    if (keyBitLength == 128)     {
-        k[4] = s0, k[5] = s1, k[6] = s2, k[7] = s3;
-      }
-    else     {
-        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;
-        s0 ^= k[8], s1 ^= k[9], s2 ^= k[10], s3 ^= k[11];
-        do    {
-  	  register u32 _t0, _t1, _t2, _t3;
-  	    _t0 = s2 ^ ((SIGMA + 10))[0];
-  	      _t3 ^= Camellia_SBOX[3][(_t0 >> 8) & 0xff];
-  	        s1 ^= _t3;
-  		}
-        while (0);
-        do    {
-  	  u32 _t0 = s0 >> (32 - 30);
-  	    s2 = (s2 << 30) | (s3 >> (32 - 30));
-  	      s3 = (s3 << 30) | _t0;
-  	      }
-        while (0);
-        k[40] = s0, k[41] = s1, k[42] = s2, k[43] = s3;
-        k[64] = s1, k[65] = s2, k[66] = s3, k[67] = s0;
-        s0 = k[8], s1 = k[9], s2 = k[10], s3 = k[11];
-        k[36] = s0, k[37] = s1, k[38] = s2, k[39] = s3;
-        s0 = k[12], s1 = k[13], s2 = k[14], s3 = k[15];
-        do   {
-  	  s1 = (s1 << 15) | (s2 >> (32 - 15));
-  	  }
-        while (0);
-        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;
-        k[44] = s1, k[45] = s2, k[46] = s3, k[47] = s0;
-      }
-  }