[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-24 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

--- Comment #5 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Tue Nov 24 09:31:57 2015
New Revision: 230795

URL: https://gcc.gnu.org/viewcvs?rev=230795=gcc=rev
Log:
[RTL-ree] PR rtl-optimization/68194: Restrict copy instruction in presence of
conditional moves

PR rtl-optimization/68194
PR rtl-optimization/68328
PR rtl-optimization/68185
* ree.c (combine_reaching_defs): Reject copy_needed case if
copies_list is not empty.

* gcc.c-torture/execute/pr68185.c: New test.
* gcc.c-torture/execute/pr68328.c: Likewise.


Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr68185.c
trunk/gcc/testsuite/gcc.c-torture/execute/pr68328.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ree.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-24 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

--- Comment #7 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Tue Nov 24 14:27:51 2015
New Revision: 230813

URL: https://gcc.gnu.org/viewcvs?rev=230813=gcc=rev
Log:
[RTL-ree] PR rtl-optimization/68194: Restrict copy instruction in presence of
conditional moves

Backport from mainline
2015-11-24  Bernd Schmidt 
Kyrylo Tkachov  

PR rtl-optimization/68194
PR rtl-optimization/68328
PR rtl-optimization/68185
* ree.c (combine_reaching_defs): Reject copy_needed case if
copies_list is not empty.

* gcc.c-torture/execute/pr68185.c: New test.
* gcc.c-torture/execute/pr68328.c: Likewise.

Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/pr68185.c
branches/gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/pr68328.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/ree.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog

[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-24 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

--- Comment #6 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Tue Nov 24 14:24:24 2015
New Revision: 230812

URL: https://gcc.gnu.org/viewcvs?rev=230812=gcc=rev
Log:
[RTL-ree] PR rtl-optimization/68194: Restrict copy instruction in presence of
conditional moves

PR rtl-optimization/68194
PR rtl-optimization/68328
PR rtl-optimization/68185
* ree.c (combine_reaching_defs): Reject copy_needed case if
copies_list is not empty.

* gcc.c-torture/execute/pr68185.c: New test.
* gcc.c-torture/execute/pr68328.c: Likewise.

Added:
branches/gcc-5-branch/gcc/testsuite/gcc.c-torture/execute/pr68185.c
branches/gcc-5-branch/gcc/testsuite/gcc.c-torture/execute/pr68328.c
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/ree.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog

[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-23 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

Jeffrey A. Law  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 CC||law at redhat dot com
 Resolution|--- |DUPLICATE

--- Comment #4 from Jeffrey A. Law  ---
Same issue as 68194.

*** This bug has been marked as a duplicate of bug 68194 ***

[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-13 Thread thopre01 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

--- Comment #3 from Thomas Preud'homme  ---
Things start to go awry in the get_defs called at the end of
make_defs_and_copies_lists for conditional move in ree.c. ree correctly detect
that insn 308 is a conditional move and do the transitive closure on it in
search for its definition. It finds insn 304 as the definition for register di
but then screw up by finding insn 308 itself as the definition for bp in insn
308.

This all happens in get_defs that uses df information. For insn 308, there is
only one link in the use-def chain for the dp use and the ref for that link
points to insn 308.

I'm not sure if it's a failure of df to link the use to the def being done in
the same instruction or if it's ree failing to detect this. If the latter, I
guess the fix would be to ignore a def to the same instruction and return an
error if there is only that def (so add a counter in the last loop).

[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-10 Thread thopre01 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

--- Comment #2 from Thomas Preud'homme  ---
Here's a quick update. What I found so far is that after split2, we have:

(insn 148 61 304 16 (set (reg:CCNO 17 flags)
(compare:CCNO (reg:HI 44 r15 [orig:91 pretmp_9 ] [91])
(const_int 0 [0]))) pr68185.c:20 2 {*cmphi_ccno_1}
 (nil))
(insn 304 148 308 16 (set (reg/v:QI 5 di [orig:98 g ] [98])
(mem/c:QI (plus:DI (reg/f:DI 7 sp)
(const_int 15 [0xf])) [3 %sfp+-1 S1 A8])) pr68185.c:20 89
{*movqi_internal}
 (nil))
(insn 308 304 67 16 (set (reg:SI 6 bp [orig:90 g ] [90])
(if_then_else:SI (gt (reg:CCNO 17 flags)
(const_int 0 [0]))
(reg:SI 6 bp [orig:90 g ] [90])
(reg:SI 5 di [orig:98 g ] [98]))) pr68185.c:20 957 {*movsicc_noc}
 (nil))
(insn 67 308 151 16 (set (reg:SI 1 dx [orig:99 _23 ] [99])
(sign_extend:SI (reg/v:QI 6 bp [orig:90 g ] [90]))) pr68185.c:21 149
{extendqisi2}
 (nil))

Where the second instruction load the value of w on the stack into di, then the
third instruction set bp to that value if t (in reg:HI 44) is smaller or equal
to 0 and then this value is extended into dx.

But after ree has run, we have:

(insn 148 61 304 16 (set (reg:CCNO 17 flags)
(compare:CCNO (reg:HI 44 r15 [orig:91 pretmp_9 ] [91])
(const_int 0 [0]))) pr68185.c:20 2 {*cmphi_ccno_1}
 (nil))
(insn 304 148 312 16 (set (reg:SI 1 dx)
(sign_extend:SI (mem/c:QI (plus:DI (reg/f:DI 7 sp)
(const_int 15 [0xf])) [3 %sfp+-1 S1 A8]))) pr68185.c:20 149
{extendqisi2}
 (nil))
(insn 312 304 308 16 (set (reg:SI 6 bp)
(reg:SI 1 dx)) pr68185.c:20 -1
 (nil))
(insn 308 312 151 16 (set (reg:SI 6 bp [orig:90 g ] [90])
(if_then_else:SI (gt (reg:CCNO 17 flags)
(const_int 0 [0]))
(reg:SI 6 bp [orig:90 g ] [90])
(reg:SI 5 di [orig:98 g ] [98]))) pr68185.c:20 957 {*movsicc_noc}
 (nil))

So the extension happens first from the value of w on the stack (insn 304),
then that value is put into bp (insn 312) and then bp takes the value of di
(which equals 0 at this point, coming from z I believe) if t (in reg:HI 44) is
smaller or equal to 0.

So the condition seems to have been reversed. This in turn leads to q not being
set to 1 after and thus the abort. Next step will be to investigate why ree
think this is safe to do, maybe some meta information not represented here that
was not updated correctly by loop2_invariant.

[Bug rtl-optimization/68185] [6 Regression] wrong code at -O3 on x86_64-linux-gnu (in 64-bit mode)

2015-11-08 Thread thopre01 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68185

Thomas Preud'homme  changed:

   What|Removed |Added

 Target||x86_64-linux-gnu
 Status|NEW |ASSIGNED
 CC||thopre01 at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |thopre01 at gcc dot 
gnu.org