public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14562] New: Incorrect loop code caused by pass_ch
@ 2004-03-12 21:25 fjahanian at apple dot com
  2004-03-12 22:22 ` [Bug optimization/14562] " fjahanian at apple dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: fjahanian at apple dot com @ 2004-03-12 21:25 UTC (permalink / raw)
  To: gcc-bugs

Following test case produces incorrect PHI functions in pacc_ch, when compiled with
tree-ssa compiler with -O1 on ppc-darwin. This prevents gap of the SPEC benchmark
to build correctly with -O1 and higher optimizations.

typedef struct TypHeader {
    unsigned long size;
    struct TypHeader * * ptr;
} * TypHandle;

TypHandle gorf (unsigned long h, unsigned long k, TypHandle hdRes, TypHandle hdTmp)
{
    while ( hdTmp < ((hdRes)->ptr)[k-h] ) {
         ((hdRes)->ptr)[k] = ((hdRes)->ptr)[k-h];
         k = k-h;
    }
    return hdRes;
}


gorf (h, k, hdRes, hdTmp)
{
  struct TypHeader * * T.8;
  struct TypHeader * * T.7;
  long unsigned int T.6;
  struct TypHeader * T.5;
  struct TypHeader * * T.4;
  struct TypHeader * * T.3;
  long unsigned int T.2;
  long unsigned int T.1;
  struct TypHeader * * T.0;
  
  # BLOCK 0
  # PRED: ENTRY (fallthru)
  T.0<D1054>_26 = hdRes<D1048>_3->ptr;
  T.1<D1055>_27 = k<D1047>_2 - h<D1046>_5;
  T.2<D1056>_28 = T.1<D1055>_27 * 4;
  T.3<D1057>_29 = (struct TypHeader * *)T.2<D1056>_28;
  T.4<D1058>_30 = T.0<D1054>_26 + T.3<D1057>_29;
  T.5<D1059>_31 = *T.4<D1058>_30;

  if (T.5<D1059>_31 > hdTmp<D1049>_11) goto <L0>; else goto <L2>;

  # SUCC: 1 (true) 2 (false)

  # BLOCK 1
  # PRED: 0 (true) 1 (true)
  # T.3<D1057>_25 = PHI <T.3<D1057>_29(0), T.3<D1057>_40(1)>;
  # T.1<D1055>_24 = PHI <T.1<D1055>_27(0), T.1<D1055>_38(1)>;
  # k<D1047>_1 = PHI <k<D1047>_2(0), k<D1047>_36(1)>;

<L0>:;
  T.0<D1054>_32 = hdRes<D1048>_3->ptr;
  T.6<D1061>_14 = k<D1047>_1 * 4;
  T.7<D1062>_15 = (struct TypHeader * *)T.6<D1061>_14;
  T.8<D1063>_16 = T.0<D1054>_32 + T.7<D1062>_15;
  T.0<D1054>_33 = hdRes<D1048>_3->ptr;
  T.4<D1058>_34 = T.0<D1054>_33 + T.3<D1057>_25;
  T.5<D1059>_35 = *T.4<D1058>_34;
  *T.8<D1063>_16 = T.5<D1059>_35;
  k<D1047>_36 = T.1<D1055>_24;
  T.0<D1054>_37 = hdRes<D1048>_3->ptr;
  T.1<D1055>_38 = k<D1047>_36 - h<D1046>_5;
  T.2<D1056>_39 = T.1<D1055>_38 * 4;
  T.3<D1057>_40 = (struct TypHeader * *)T.2<D1056>_39;
  T.4<D1058>_41 = T.0<D1054>_37 + T.3<D1057>_40;
  T.5<D1059>_42 = *T.4<D1058>_41;
  if (T.5<D1059>_42 > hdTmp<D1049>_11) goto <L0>; else goto <L2>;
  # SUCC: 2 (false) 1 (true)

  # BLOCK 2
  # PRED: 0 (false) 1 (false)
<L2>:;
  return hdRes<D1048>_3;
  # SUCC: EXIT

}


2004-02-20  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
...

      * tree-optimize.c (init_tree_optimization_passes): Add pass_ch.
        * tree-pass.h (pass_ch): Declare.
        * tree-ssa-loop.c: Include tree-inline.h.
        (call_expr_p, should_duplicate_loop_header_p, mark_defs_for_rewrite,
        duplicate_blocks, copy_loop_headers, gate_ch): New functions.
        (pass_ch): New.
...

- fariborz (fjahanian@apple.com)

-- 
           Summary: Incorrect loop code caused by pass_ch
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: optimization
        AssignedTo: rakdver at atrey dot karlin dot mff dot cuni dot cz
        ReportedBy: fjahanian at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.2.0
  GCC host triplet: powerpc-apple-darwin7.2.0
GCC target triplet: powerpc-apple-darwin7.2.0


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug optimization/14562] Incorrect loop code caused by pass_ch
  2004-03-12 21:25 [Bug optimization/14562] New: Incorrect loop code caused by pass_ch fjahanian at apple dot com
@ 2004-03-12 22:22 ` fjahanian at apple dot com
  2004-03-12 22:29 ` [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by copyrename pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fjahanian at apple dot com @ 2004-03-12 22:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fjahanian at apple dot com  2004-03-12 22:22 -------
Here is an executable test case:

typedef struct TypHeader {
    unsigned long size;
    struct TypHeader * * ptr;
} * TypHandle;

void gorf (unsigned long h, unsigned long k, TypHandle hdRes, TypHandle hdTmp)
{
    while ( hdTmp < ((hdRes)->ptr)[k-h] ) {
         ((hdRes)->ptr)[k] = ((hdRes)->ptr)[k-h];
         k = k-h;
    }
}

int main()
{
        int i;
        struct TypHeader* arrTypHeader[6];
        TypHandle hdTmp;

        struct TypHeader hd;
        hd.ptr = arrTypHeader;

        for (i=0; i < 6; i++)
        {
           arrTypHeader[i] = (struct TypHeader*)malloc(sizeof(struct TypHeader));
           arrTypHeader[i]->size = i;
        }

        gorf(1, 5, &hd, arrTypHeader[0]);
        for (i=0; i < 6; i++)
        {
           printf(" size = %d\n", arrTypHeader[i]->size);
        }

        return 0;
}

Compiled with -O0 produces following results:

 size = 0
 size = 1
 size = 1
 size = 2
 size = 3
 size = 4


Compiled with -O1 produces incorrect results:

 size = 0
 size = 1
 size = 2
 size = 3
 size = 4
 size = 5

-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by copyrename
  2004-03-12 21:25 [Bug optimization/14562] New: Incorrect loop code caused by pass_ch fjahanian at apple dot com
  2004-03-12 22:22 ` [Bug optimization/14562] " fjahanian at apple dot com
@ 2004-03-12 22:29 ` pinskia at gcc dot gnu dot org
  2004-03-15 23:20 ` [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by PRE pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-12 22:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-12 22:29 -------
Actually the PHI functions from tree copy header are fine, the real issue is that copyrename is renaming
a variable to one which is set also through the loop.
I found this seeing that copyrename2 was messing up the trees.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|rakdver at atrey dot karlin |amacleod at redhat dot com
                   |dot mff dot cuni dot cz     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-12 22:29:31
               date|                            |
            Summary|Incorrect loop code caused  |[tree-ssa] Incorrect loop
                   |by pass_ch                  |code caused by copyrename
   Target Milestone|---                         |tree-ssa


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by PRE
  2004-03-12 21:25 [Bug optimization/14562] New: Incorrect loop code caused by pass_ch fjahanian at apple dot com
  2004-03-12 22:22 ` [Bug optimization/14562] " fjahanian at apple dot com
  2004-03-12 22:29 ` [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by copyrename pinskia at gcc dot gnu dot org
@ 2004-03-15 23:20 ` pinskia at gcc dot gnu dot org
  2004-03-16 15:59 ` cvs-commit at gcc dot gnu dot org
  2004-03-16 16:00 ` dberlin at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-15 23:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-15 23:20 -------
The problem was caused by PRE not knowing that the two PHI's were in fact different so it was choosing 
the wrong one.
See <http://gcc.gnu.org/ml/gcc-bugs/2004-03/msg01821.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
         AssignedTo|amacleod at redhat dot com  |dberlin at gcc dot gnu dot
                   |                            |org
            Summary|[tree-ssa] Incorrect loop   |[tree-ssa] Incorrect loop
                   |code caused by copyrename   |code caused by PRE


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by PRE
  2004-03-12 21:25 [Bug optimization/14562] New: Incorrect loop code caused by pass_ch fjahanian at apple dot com
                   ` (2 preceding siblings ...)
  2004-03-15 23:20 ` [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by PRE pinskia at gcc dot gnu dot org
@ 2004-03-16 15:59 ` cvs-commit at gcc dot gnu dot org
  2004-03-16 16:00 ` dberlin at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-03-16 15:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-03-16 15:59 -------
Subject: Bug 14562

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	tree-ssa-20020619-branch
Changes by:	dberlin@gcc.gnu.org	2004-03-16 15:59:30

Modified files:
	gcc            : ChangeLog.tree-ssa tree-ssa-pre.c 

Log message:
	2004-03-16  Daniel Berlin  <dberlin@dberlin.org>
	
	PR optimization/14562
	* tree-ssa-pre.c (generate_expr_as_of_bb): Don't use names_match_p.
	(generate_vops_as_of_bb): Ditto.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.1272&r2=1.1.2.1273
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-pre.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.4.132&r2=1.1.4.133



-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by PRE
  2004-03-12 21:25 [Bug optimization/14562] New: Incorrect loop code caused by pass_ch fjahanian at apple dot com
                   ` (3 preceding siblings ...)
  2004-03-16 15:59 ` cvs-commit at gcc dot gnu dot org
@ 2004-03-16 16:00 ` dberlin at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: dberlin at gcc dot gnu dot org @ 2004-03-16 16:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dberlin at gcc dot gnu dot org  2004-03-16 16:00 -------
Fixed

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-03-16 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-12 21:25 [Bug optimization/14562] New: Incorrect loop code caused by pass_ch fjahanian at apple dot com
2004-03-12 22:22 ` [Bug optimization/14562] " fjahanian at apple dot com
2004-03-12 22:29 ` [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by copyrename pinskia at gcc dot gnu dot org
2004-03-15 23:20 ` [Bug optimization/14562] [tree-ssa] Incorrect loop code caused by PRE pinskia at gcc dot gnu dot org
2004-03-16 15:59 ` cvs-commit at gcc dot gnu dot org
2004-03-16 16:00 ` dberlin at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).