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][4.1] Fix PR tree-optimization/26587, wrong PT alias information


This patch fixes PR26587 where we create wrong PTA information which leads
to wrong code later.

Bootstrapped and tested on x86_64-unknown-linux-gnu,

ok for 4.1 branch?  A similar fix ok for 4.2 or do we want to do more
interesting things with negative offsets there?  (looks not so easy, 
because offsets are unsigned everywhere)

Thanks,
Richard.


:ADDPATCH aliasing:

2006-03-07  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/26587
        * tree-ssa-structalias.c (handle_ptr_arith): Handle MINUS_EXPR.

        * gcc.dg/torture/pr26587.c: New testcase.

Index: gcc/testsuite/gcc.dg/torture/pr26587.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr26587.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr26587.c	(revision 0)
***************
*** 0 ****
--- 1,28 ----
+ /* { dg-do run } */
+ 
+ extern void abort(void);
+ typedef unsigned int BF_word;
+ typedef BF_word BF_key[16 + 2];
+ static struct {
+     BF_key P;
+ } BF_current;
+ int main(void)
+ {   
+     BF_word L;
+     BF_word tmp4, *ptr;
+     BF_word i;
+     for (i = 0; i < 16 + 2; i++)
+         BF_current.P[i] = i * 0x98765432;
+     L = 0;
+     ptr = BF_current.P;
+     do {
+         ptr += 2;
+         L ^= BF_current.P[0];
+         tmp4 = L >> 24;
+         L = tmp4 ^ BF_current.P[16 + 1];
+         *(ptr - 2) = L;
+     } while (ptr < &BF_current.P[16 + 2]);
+     if (L != 0x1fdb9752)
+         abort();
+     return 0;
+ }
Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 111804)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** handle_ptr_arith (struct constraint_expr
*** 2837,2843 ****
    tree op0, op1;
    struct constraint_expr base, offset;
  
!   if (TREE_CODE (expr) != PLUS_EXPR)
      return false;
  
    op0 = TREE_OPERAND (expr, 0);
--- 2837,2844 ----
    tree op0, op1;
    struct constraint_expr base, offset;
  
!   if (TREE_CODE (expr) != PLUS_EXPR
!       && TREE_CODE (expr) != MINUS_EXPR)
      return false;
  
    op0 = TREE_OPERAND (expr, 0);


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