This is the mail archive of the gcc-prs@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]

c/3128: gcc3.0 miscompiles Linux/ia64 kernel



>Number:         3128
>Category:       c
>Synopsis:       gcc3.0 miscompiles Linux/ia64 kernel
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 11 14:06:05 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     davidm@hpl.hp.com
>Release:        3.0 (prerelease)
>Organization:
>Environment:
IA-64 Linux
>Description:
The attached program gets miscompiled when optimization is turned on.
If I drop the optimization level to -O, then I get the expected output (uaddr=0x400000).  I also tried adding -fno-schedule-insns2 but it makes no difference in this case.

>How-To-Repeat:
$ /usr/gcc-pre3.0/bin/gcc -v
Reading specs from /usr/gcc-pre3.0/lib/gcc-lib/ia64-hp-linux/3.0/specs
Configured with: ../gcc/configure --host=ia64-hp-linux --prefix=/usr/gcc-pre3.0 : (reconfigured) ../gcc/configure --host=ia64-hp-linux --prefix=/usr/gcc-pre3.0
Thread model: single
gcc version 3.0 20010515 (prerelease)
$ /usr/gcc-pre3.0/bin/gcc -Wall -O2 bug-nargs.c
$ ./a.out
uaddr=(nil)
>Fix:
Jim Wilson was able to fix the problem with the attached patch, but this
fix hasn't made it into the 3.0 tree yet.

2001-05-21  Jim Wilson  <wilson@redhat.com>

        * loop.c (strength_reduce): Move bl->all_reduced set before
        check_ext_dependant_givs call.
        (check_ext_dependant_givs): Clear bl->all_reduced when ignoring givs.

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.333
diff -p -r1.333 loop.c
*** loop.c      2001/05/11 15:52:38     1.333
--- loop.c      2001/05/22 00:36:48
*************** strength_reduce (loop, flags)
*** 4304,4309 ****
--- 4304,4314 ----
         provided all givs are reduced.  */
        bl->eliminable = loop_biv_eliminable_p (loop, bl, threshold, insn_count);
  
+       /* This will be true at the end, if all givs which depend on this
+        biv have been strength reduced.
+        We can't (currently) eliminate the biv unless this is so.  */
+       bl->all_reduced = 1;
+ 
        /* Check each extension dependent giv in this class to see if its
         root biv is safe from wrapping in the interior mode.  */
        check_ext_dependant_givs (bl, loop_info);
*************** strength_reduce (loop, flags)
*** 4311,4321 ****
        /* Combine all giv's for this iv_class.  */
        combine_givs (regs, bl);
  
-       /* This will be true at the end, if all givs which depend on this
-        biv have been strength reduced.
-        We can't (currently) eliminate the biv unless this is so.  */
-       bl->all_reduced = 1;
- 
        for (v = bl->giv; v; v = v->next_iv)
        {
          struct induction *tv;
--- 4316,4321 ----
*************** check_ext_dependant_givs (bl, loop_info)
*** 6646,6651 ****
--- 6646,6652 ----
                         INSN_UID (v->insn), why);
              }
            v->ignore = 1;
+           bl->all_reduced = 0;
          }
        }
  }


>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug-nargs.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug-nargs.c"

I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQKZG9fZ2V0X3VzZXIgKGludCAqdmFyLCBpbnQgKnVhZGRy
KQp7CglwcmludGYgKCJ1YWRkcj0lcFxuIiwgdWFkZHIpOwoJKnZhciA9IDEzOwoJcmV0dXJuIDA7
Cn0KCnN0YXRpYyBpbnQKbmFyZ3MgKHVuc2lnbmVkIGludCBhcmcsIGNoYXIgKiphcCkKewoJaW50
IGVyciwgYWRkcjsKCglpZiAoIWFyZykKCQlyZXR1cm4gMDsKCglkbyB7CgkJZXJyID0gZG9fZ2V0
X3VzZXIoJmFkZHIsIChpbnQgKikobG9uZykgYXJnKTsKCQlpZiAoZXJyKQoJCQlyZXR1cm4gMDsK
CQkqYXAgPSAoY2hhciAqKSAobG9uZykgYWRkcjsKCQlhcmcgKz0gNDsKCX0gd2hpbGUgKGFkZHIp
OwoJcmV0dXJuIDA7Cn0KCmludAptYWluIChpbnQgYXJnYywgY2hhciAqKmFyZ3YpCnsKCWNoYXIg
KmFwWzFdOwoKCW5hcmdzKDB4NDAwMDAwLCBhcCk7CglyZXR1cm4gMDsKfQo=


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