Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 14187
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: dann@godzilla.ics.uci.edu
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 14187 depends on: Show dependency tree
Show dependency graph
Bug 14187 blocks: 14192 15623 16913 33272 37694 37695 37696

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2006-01-13 04:45 Opened: 2004-02-18 08:20
Given:
extern void link_error (void);

void bar0 (int * __restrict__ arr1, int * __restrict__ arr2)
{
  arr1[0] = 1;
  arr2[0] = 1;
  if (arr1[0] != 1)
    link_error ();
}

arr1 and arr2 should not alias, hence the "if" should be eliminated

The .optimized dump is: 

bar0 (arr1, arr2)
{
<bb 0>:
  #   TMT.46_5 = VDEF <TMT.46_4>;
  *arr1 = 1;
  #   TMT.46_6 = VDEF <TMT.46_5>;
  *arr2 = 1;
  if (*arr1 != 1) goto <L0>; else goto <L1>;

<L0>:;
  #   TMT.46_7 = VDEF <TMT.46_6>;
  link_error ();

<L1>:;
  return;

}

------- Comment #1 From Falk Hueffner 2004-02-18 11:04 -------
Works for me with GNU C version 3.5-tree-ssa 20040217 (merged
20040211) (alphaev68-unknown-linux-gnu):

0000000000000000 <bar0>:
   0:   01 00 3f 20     lda     t0,1
   4:   00 00 31 b0     stl     t0,0(a1)
   8:   00 00 30 b0     stl     t0,0(a0)
   c:   01 80 fa 6b     ret

Which version and target are you seeing this problem for?

------- Comment #2 From Andrew Pinski 2004-02-18 13:06 -------
Confirmed.

------- Comment #3 From dann@godzilla.ics.uci.edu 2004-03-12 17:15 -------
Interestingly the following code is optimized:

#include <stdlib.h>

extern int foo (int * , int *);
void bar1 (void)
{
  int * arr1 = malloc (12);
  int * arr2 = malloc (12);
  arr1[0] = 1;
  arr2[0] = 1;
  if (arr1[0] != 1)
    link_error ();
  foo (arr1, arr2);
}

------- Comment #4 From Andrew Pinski 2004-07-02 00:19 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00116.html>.

------- Comment #5 From Andrew Pinski 2007-06-11 00:48 -------
(In reply to comment #3)
> Interestingly the following code is optimized:
That is because we create a new may_alias variable for malloc to point to so we
know that it cannot alias anything.

------- Comment #6 From Richard Guenther 2008-10-01 14:28 -------
*** Bug 14192 has been marked as a duplicate of this bug. ***

------- Comment #7 From Richard Guenther 2008-10-01 14:30 -------
Note that C restrict semantics make it necessary to properly track what
pointer is based on what other pointer.  For this we miss both annotations
and a (simple) propagator that propagates this information, maybe as part
of PTA analysis.

Note that the current implementation has both missed-optimization and latent
wrong-code issues.

------- Comment #8 From Richard Guenther 2008-10-01 14:32 -------
*** Bug 16306 has been marked as a duplicate of this bug. ***

------- Comment #9 From Richard Guenther 2008-10-01 14:33 -------
*** Bug 16913 has been marked as a duplicate of this bug. ***

------- Comment #10 From Richard Guenther 2008-10-01 14:34 -------
*** Bug 28030 has been marked as a duplicate of this bug. ***

------- Comment #11 From Richard Guenther 2008-10-01 14:35 -------
*** Bug 29239 has been marked as a duplicate of this bug. ***

------- Comment #12 From Richard Guenther 2008-10-01 14:35 -------
*** Bug 32273 has been marked as a duplicate of this bug. ***

------- Comment #13 From Richard Guenther 2008-10-01 14:38 -------
*** Bug 33272 has been marked as a duplicate of this bug. ***

------- Comment #14 From Richard Guenther 2008-10-01 14:40 -------
*** Bug 33705 has been marked as a duplicate of this bug. ***

------- Comment #15 From Richard Guenther 2008-10-01 15:01 -------
This is not solely a tree issue.

------- Comment #16 From Richard Guenther 2009-06-29 12:23 -------
Subject: Bug 14187

Author: rguenth
Date: Mon Jun 29 12:23:21 2009
New Revision: 149048

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149048
Log:
2009-06-29  Richard Guenther  <rguenther@suse.de>

        PR middle-end/14187
        * tree-ssa-alias.h (struct pt_solution): Add vars_contains_restrict
        flag.
        (pt_solutions_same_restrict_base): Declare.
        * tree-ssa-structalias.c (struct variable_info): Add is_restrict_var
        flag.
        (new_var_info): Initialize is_global_var properly for SSA_NAMEs.
        (make_constraint_from, make_copy_constraint): Move earlier.
        (make_constraint_from_heapvar): New function.
        (make_constraint_from_restrict): Likewise.
        (handle_lhs_call): Use it.
        (find_func_aliases): Use it to track conversions to restrict
        qualified pointers.
        (struct fieldoff): Add only_restrict_pointers flag.
        (push_fields_onto_fieldstack): Initialize it.
        (create_variable_info_for): Track global restrict qualified pointers.
        (intra_create_variable_infos): Use make_constraint_from_heapvar.
        Track restrict qualified pointer arguments.
        (set_uids_in_ptset): Use varinfo is_global_var flag.
        (find_what_var_points_to): Set the vars_contains_restrict flag.
        Always create the points-to solution for sets including restrict tags.
        (pt_solutions_same_restrict_base): New function.
        * tree-ssa-alias.c (ptr_derefs_may_alias_p): For two restrict
        qualified pointers use pt_solutions_same_restrict_base as
        additional source for disambiguation.

        * gcc.dg/tree-ssa/restrict-1.c: New testcase.
        * gcc.dg/tree-ssa/restrict-2.c: Likewise.
        * gcc.dg/tree-ssa/restrict-3.c: Likewise.
        * gcc.c-torture/execute/20090623-1.c: Likewise.
        * gcc.dg/tree-ssa/ldist-13.c: Likewise.
        * gcc.dg/tree-ssa/ldist-14.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/20090623-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ldist-13.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ldist-14.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/restrict-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/restrict-2.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/restrict-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-alias.c
    trunk/gcc/tree-ssa-alias.h
    trunk/gcc/tree-ssa-structalias.c

------- Comment #17 From Richard Guenther 2009-06-29 12:24 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug