public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/44852]  New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge
@ 2010-07-07  3:39 hp at gcc dot gnu dot org
  2010-07-07  3:44 ` [Bug middle-end/44852] " hp at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: hp at gcc dot gnu dot org @ 2010-07-07  3:39 UTC (permalink / raw)
  To: gcc-bugs

Revision 161654 compiles the attached test-case correctly at -O2.
Revision 161655 does not (except at -O0).

I guess the bug is apparent for other targets too, but I haven't checked.

Note for cris-elf this bb, correctly compiled (path for *s = '0' to sf return):
.L7:
        move.b 48,$r13
        move.b $r13,[$r11]
        addq 1,$r13
        ret
        move.b $r13,[$r9]

and incorrectly:
.L7:
        move.b 48,$r9
        move.b $r9,[$r10-1]
        addq 10,$r9
        move.b $r9,[$r10-1]
        ret
        nop

(storing '0' and then adding 10 to it, making ':')

The test-case is distilled from newlib/libc/stdlib/dtoa.c, where the bug causes
a store of ':' directly, without bothering to first store '0' :) but apparently
the same bug.

The miscompilation is exposed as regressions in three fortran test-cases from
r161655 and on, up to and including at least r161893:

Running /tmp/regress-0630-55/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
... (non-regressions elided)
FAIL: gfortran.dg/edit_real_1.f90  -O0  execution test
FAIL: gfortran.dg/edit_real_1.f90  -O1  execution test
FAIL: gfortran.dg/edit_real_1.f90  -O2  execution test
FAIL: gfortran.dg/edit_real_1.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/edit_real_1.f90  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/edit_real_1.f90  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/edit_real_1.f90  -O3 -g  execution test
FAIL: gfortran.dg/edit_real_1.f90  -Os  execution test
FAIL: gfortran.dg/fmt_float.f90  -O0  output pattern test, is            
0.10E+01            0.10E+00            0.:0E\
(...verbosity elided but note the ":"; there's a "1" expected there)
FAIL: gfortran.dg/fmt_float.f90  -O1  output pattern test, is            
0.10E+01            0.10E+00            0.:0E\
(...further similar fmt_float results elided)
FAIL: gfortran.dg/fmt_zero_precision.f90  -O0  output pattern test, is  1.<
(...verbosity elided)
FAIL: gfortran.dg/fmt_zero_precision.f90  -O1  output pattern test, is  1.<
(...further similar fmt_zero_precision results elided)


-- 
           Summary: [4.6 Regression]: miscompilation of newlib dtoa.c after
                    mem-ref2 merge
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hp at gcc dot gnu dot org
  GCC host triplet: x86_64-linux
GCC target triplet: cris-elf


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
@ 2010-07-07  3:44 ` hp at gcc dot gnu dot org
  2010-07-07  3:50 ` hp at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hp at gcc dot gnu dot org @ 2010-07-07  3:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from hp at gcc dot gnu dot org  2010-07-07 03:44 -------
Created an attachment (id=21119)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21119&action=view)
test-case suggested for gcc.c-torture/execute

Compile at e.g. -O2, observe code in PR description, also observed for r161899.


-- 


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
  2010-07-07  3:44 ` [Bug middle-end/44852] " hp at gcc dot gnu dot org
@ 2010-07-07  3:50 ` hp at gcc dot gnu dot org
  2010-07-07 10:27 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hp at gcc dot gnu dot org @ 2010-07-07  3:50 UTC (permalink / raw)
  To: gcc-bugs



-- 

hp at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-07 03:49:56
               date|                            |


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
  2010-07-07  3:44 ` [Bug middle-end/44852] " hp at gcc dot gnu dot org
  2010-07-07  3:50 ` hp at gcc dot gnu dot org
@ 2010-07-07 10:27 ` rguenth at gcc dot gnu dot org
  2010-07-07 11:22 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-07 10:27 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.6.0


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-07-07 10:27 ` rguenth at gcc dot gnu dot org
@ 2010-07-07 11:22 ` rguenth at gcc dot gnu dot org
  2010-07-07 16:25 ` hp at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-07 11:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-07-07 11:22 -------
The addition by 10 appears during postreload, where we substitute

(insn 24 35 65 4 t.i:9 (set (reg:QI 9 r9 [orig:44 prephitmp.3 ] [44])
        (const_int 58 [0x3a])) 45 {movqi} (expr_list:REG_EQUAL (const_int 58
[0x3a])
        (nil)))

for

(insn 24 35 65 4 t.i:9 (set (reg:QI 9 r9 [orig:44 prephitmp.3 ] [44])
        (plus:QI (reg:QI 9 r9 [orig:44 prephitmp.3 ] [44])
            (const_int 10 [0xa]))) 77 {*addqi3_non_v32} (expr_list:REG_EQUAL
(const_int 58 [0x3a])
        (nil)))

in

(insn 69 34 35 4 t.i:8 (set (reg:QI 9 r9)
        (const_int 48 [0x30])) 45 {movqi} (nil))

(insn 35 69 24 4 t.i:8 (set (mem:QI (plus:SI (reg/v/f:SI 10 r10 [orig:47 s ]
[47])
                (const_int -1 [0xffffffffffffffff])) [0 MEM[(char *)s_22 +
4294967295B]+0 S1 A8])
        (reg:QI 9 r9)) 45 {movqi} (nil))

(insn 24 35 65 4 t.i:9 (set (reg:QI 9 r9 [orig:44 prephitmp.3 ] [44])
        (const_int 58 [0x3a])) 45 {movqi} (expr_list:REG_EQUAL (const_int 58
[0x3a])
        (nil)))

which by itself doesn't look wrong.


-- 


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-07-07 11:22 ` rguenth at gcc dot gnu dot org
@ 2010-07-07 16:25 ` hp at gcc dot gnu dot org
  2010-07-08 16:27 ` [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) " hp at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hp at gcc dot gnu dot org @ 2010-07-07 16:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hp at gcc dot gnu dot org  2010-07-07 16:24 -------
(In reply to comment #2)
> The addition by 10 appears during postreload, where we substitute
> ...
> which by itself doesn't look wrong.

That's right, if the two stores had been to different locations, it'd have been
optimal (the add by 10 being shorter than loading the constant 0x3a; no
scheduling issues).

But, JFTR, that observation is just incidental and beside the point.


-- 


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-07-07 16:25 ` hp at gcc dot gnu dot org
@ 2010-07-08 16:27 ` hp at gcc dot gnu dot org
  2010-07-08 21:40 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hp at gcc dot gnu dot org @ 2010-07-08 16:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hp at gcc dot gnu dot org  2010-07-08 16:27 -------
Removing target specifier as the test-case fails for native x86_64-linux as
well, with e.g. r161957, so there's reason to believe the miscompilation is
generic.
Just mentioned in case there's a target-based priority involved.


-- 

hp at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|cris-elf                    |
            Summary|[4.6 Regression]:           |[4.6 Regression]:
                   |miscompilation of newlib    |miscompilation (of e.g.
                   |dtoa.c after mem-ref2 merge |newlib dtoa.c) after mem-
                   |                            |ref2 merge


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-07-08 16:27 ` [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) " hp at gcc dot gnu dot org
@ 2010-07-08 21:40 ` rguenth at gcc dot gnu dot org
  2010-07-08 21:57 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-08 21:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-07-08 21:39 -------
Oh. Well. Mine then.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-07-07 03:49:56         |2010-07-08 21:39:47
               date|                            |


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2010-07-08 21:40 ` rguenth at gcc dot gnu dot org
@ 2010-07-08 21:57 ` rguenth at gcc dot gnu dot org
  2010-07-09 11:24 ` rguenth at gcc dot gnu dot org
  2010-07-09 11:39 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-08 21:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2010-07-08 21:57 -------
The issue seems to be the uncprop tree pass which does

@@ -32,7 +32,7 @@

 <bb 6>:
   # s_18 = PHI <s_1(4), s_1(5)>
-  # D.1967_19 = PHI <57(4), D.1967_4(5)>
+  # D.1967_19 = PHI <D.1967_4(4), D.1967_4(5)>
   D.1968_7 = D.1967_19 + 1;
   MEM[(char *)s_18 + -1B] = D.1968_7;
   return s_18;

where D.1967_4 is defined as D.1967_4 = MEM[(char *)s_1 + -1B];

and in BB4 we define that location to MEM[(char *)s_14 + -1B] = 48;


-- 


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2010-07-08 21:57 ` rguenth at gcc dot gnu dot org
@ 2010-07-09 11:24 ` rguenth at gcc dot gnu dot org
  2010-07-09 11:39 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-09 11:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2010-07-09 11:24 -------
Subject: Bug 44852

Author: rguenth
Date: Fri Jul  9 11:24:09 2010
New Revision: 161994

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161994
Log:
2010-07-09  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/44852
        * tree-ssa-alias.c: Include toplev.h for exact_log2.
        (indirect_ref_may_alias_decl_p): Properly handle negative offsets
        in MEM_REF.
        (indirect_refs_may_alias_p): Likewise.
        * Makefile.in (tree-ssa-alias.o): Add $(TOPLEV_H).

        * gcc.c-torture/execute/pr44852.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr44852.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-alias.c


-- 


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


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

* [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) after mem-ref2 merge
  2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2010-07-09 11:24 ` rguenth at gcc dot gnu dot org
@ 2010-07-09 11:39 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-09 11:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2010-07-09 11:39 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2010-07-09 11:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07  3:39 [Bug middle-end/44852] New: [4.6 Regression]: miscompilation of newlib dtoa.c after mem-ref2 merge hp at gcc dot gnu dot org
2010-07-07  3:44 ` [Bug middle-end/44852] " hp at gcc dot gnu dot org
2010-07-07  3:50 ` hp at gcc dot gnu dot org
2010-07-07 10:27 ` rguenth at gcc dot gnu dot org
2010-07-07 11:22 ` rguenth at gcc dot gnu dot org
2010-07-07 16:25 ` hp at gcc dot gnu dot org
2010-07-08 16:27 ` [Bug middle-end/44852] [4.6 Regression]: miscompilation (of e.g. newlib dtoa.c) " hp at gcc dot gnu dot org
2010-07-08 21:40 ` rguenth at gcc dot gnu dot org
2010-07-08 21:57 ` rguenth at gcc dot gnu dot org
2010-07-09 11:24 ` rguenth at gcc dot gnu dot org
2010-07-09 11:39 ` rguenth 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).