[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-25 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

Uroš Bizjak  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from Uroš Bizjak  ---
Fixed.

[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-25 Thread uros at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

--- Comment #11 from uros at gcc dot gnu.org ---
Author: uros
Date: Sat Oct 26 06:09:02 2013
New Revision: 204088

URL: http://gcc.gnu.org/viewcvs?rev=204088&root=gcc&view=rev
Log:
Backport from mainline
2013-10-22  Uros Bizjak  

PR target/58779
* config/i386/i386.c (put_condition_code) :
Remove CCCmode handling.
: Return 'c' suffix for CCCmode.
: Return 'nc' suffix for CCCmode.
(ix86_cc_mode) : Do not generate overflow checks.
* config/i386/i386.md (*sub3_cconly_overflow): Remove.
(*sub3_cc_overflow): Ditto.
(*subsi3_zext_cc_overflow): Ditto.

Backport from mainline
2013-10-19  Uros Bizjak  

PR target/58792
* config/i386/i386.c (ix86_function_value_regno): Add DX_REG,
ST1_REG and XMM1_REG for 32bit and 64bit targets.  Also add DI_REG
and SI_REG for 64bit SYSV ABI targets.

testsuite/ChangeLog:

Backport from mainline
2013-10-22  Uros Bizjak  

PR target/58779
* gcc.target/i386/pr30315.c: Remove MINUSCC, DECCC, MINUSCCONLY
and MINUSCCZEXT defines. Update scan-assembler dg directive.
* gcc.dg/torture/pr58779.c: New test.



Added:
branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr58779.c
Modified:
branches/gcc-4_7-branch/gcc/ChangeLog
branches/gcc-4_7-branch/gcc/config/i386/i386.c
branches/gcc-4_7-branch/gcc/config/i386/i386.md
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
branches/gcc-4_7-branch/gcc/testsuite/gcc.target/i386/pr30315.c


[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-25 Thread uros at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

--- Comment #10 from uros at gcc dot gnu.org ---
Author: uros
Date: Sat Oct 26 06:02:20 2013
New Revision: 204087

URL: http://gcc.gnu.org/viewcvs?rev=204087&root=gcc&view=rev
Log:
Backport from mainline
2013-10-22  Uros Bizjak  

PR target/58779
* config/i386/i386.c (put_condition_code) :
Remove CCCmode handling.
: Return 'c' suffix for CCCmode.
: Return 'nc' suffix for CCCmode.
(ix86_cc_mode) : Do not generate overflow checks.
* config/i386/i386.md (*sub3_cconly_overflow): Remove.
(*sub3_cc_overflow): Ditto.
(*subsi3_zext_cc_overflow): Ditto.

Backport from mainline
2013-10-19  Uros Bizjak  

PR target/58792
* config/i386/i386.c (ix86_function_value_regno): Add DX_REG,
ST1_REG and XMM1_REG for 32bit and 64bit targets.  Also add DI_REG
and SI_REG for 64bit SYSV ABI targets.

testsuite/ChangeLog:

Backport from mainline
2013-10-22  Uros Bizjak  

PR target/58779
* gcc.target/i386/pr30315.c: Remove MINUSCC, DECCC, MINUSCCONLY
and MINUSCCZEXT defines. Update scan-assembler dg directive.
* gcc.dg/torture/pr58779.c: New test.


Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58779.c
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/config/i386/i386.c
branches/gcc-4_8-branch/gcc/config/i386/i386.md
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
branches/gcc-4_8-branch/gcc/testsuite/gcc.target/i386/pr30315.c


[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-22 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

--- Comment #9 from Uroš Bizjak  ---
Fixed on trunk sofar.

[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-22 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

Uroš Bizjak  changed:

   What|Removed |Added

URL||http://gcc.gnu.org/ml/gcc-p
   ||atches/2013-10/msg01826.htm
   ||l

--- Comment #8 from Uroš Bizjak  ---
Patch at [1].

[1] http://gcc.gnu.org/ml/gcc-patches/2013-10/msg01826.html

[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-22 Thread uros at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

--- Comment #7 from uros at gcc dot gnu.org ---
Author: uros
Date: Tue Oct 22 18:35:53 2013
New Revision: 203935

URL: http://gcc.gnu.org/viewcvs?rev=203935&root=gcc&view=rev
Log:
PR target/58779
* config/i386/i386.c (put_condition_code) :
Remove CCCmode handling.
: Return 'c' suffix for CCCmode.
: Return 'nc' suffix for CCCmode.
(ix86_cc_mode) : Do not generate overflow checks.
* config/i386/i386.md (*sub3_cconly_overflow): Remove.
(*sub3_cc_overflow): Ditto.
(*subsi3_zext_cc_overflow): Ditto.

testsuite/ChangeLog:

PR target/58779
* gcc.target/i386/pr30315.c: Remove MINUSCC, DECCC, MINUSCCONLY
and MINUSCCZEXT defines. Update scan-assembler dg directive.
* gcc.dg/torture/pr58779.c: New test.


Added:
trunk/gcc/testsuite/gcc.dg/torture/pr58779.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
trunk/gcc/config/i386/i386.md
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.target/i386/pr30315.c


[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-22 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

--- Comment #6 from Uroš Bizjak  ---
Created attachment 31067
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31067&action=edit
Proposed patch that removes MINUS overflow checks

Patch in testing.

[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-22 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

--- Comment #5 from Uroš Bizjak  ---
combine pass is converting:

(insn 21 20 22 4 (parallel [
(set (reg:SI 73)
(minus:SI (reg:SI 64 [ a.2 ])
(reg:SI 59 [ iftmp.3 ])))
(clobber (reg:CC 17 flags))
]) pr58779.c:8 286 {*subsi_1}
 (expr_list:REG_DEAD (reg:SI 59 [ iftmp.3 ])
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil

(insn 22 21 23 4 (set (reg:CC 17 flags)
(compare:CC (reg:SI 64 [ a.2 ])
(reg:SI 73))) pr58779.c:8 6 {*cmpsi_1}
 (expr_list:REG_DEAD (reg:SI 73)
(expr_list:REG_DEAD (reg:SI 64 [ a.2 ])
(nil

(jump_insn 23 22 24 4 (set (pc)
(if_then_else (ltu (reg:CC 17 flags)
(const_int 0 [0]))
(label_ref 27)
(pc))) pr58779.c:8 596 {*jcc_1}
 (expr_list:REG_DEAD (reg:CC 17 flags)
(expr_list:REG_BR_PROB (const_int 9996 [0x270c])
(nil)))

to:

(insn 22 21 23 4 (set (reg:CCC 17 flags)
(compare:CCC (minus:SI (reg:SI 64 [ a.2 ])
(reg:SI 59 [ iftmp.3 ]))
(reg:SI 64 [ a.2 ]))) pr58779.c:8 316 {*subsi3_cconly_overflow}
 (expr_list:REG_DEAD (reg:SI 59 [ iftmp.3 ])
(expr_list:REG_DEAD (reg:SI 64 [ a.2 ])
(nil

(jump_insn 23 22 24 4 (set (pc)
(if_then_else (gtu (reg:CCC 17 flags)
(const_int 0 [0]))
(label_ref 27)
(pc))) pr58779.c:8 596 {*jcc_1}
 (expr_list:REG_DEAD (reg:CC 17 flags)
(expr_list:REG_BR_PROB (const_int 9996 [0x270c])
(nil)))

To satisfy the *subsi3_cconly_overflow pattern, the operands of the compare are
swapped, and this reflects in changing jump insn condition from LTU to GTU.

The LTU in CCmode results in "jb" instruction, whereas GTU in CCCmode in
unpatched gcc also results in "jb". As Mikael figured out in Comment #2, we
should jump on Not-Carry condition here.

It looks to me that MINUS overflow checks are NOT modelled correctly. To hide
this problem, GTU and LEU conditions operate with inverted flag check, as can
be seen in i386.c, put_condition_code:

case GTU:
  if (mode == CCmode)
suffix = fp ? "nbe" : "a";
  else if (mode == CCCmode)
suffix = "b";
...
case LEU:
  if (mode == CCmode)
suffix = "be";
  else if (mode == CCCmode)
suffix = fp ? "nb" : "ae";
...

As can be seen from the above code, hecks in CCCmode are inverted.

So, the solution is simply to remove wrong MINUS overflow checks, as in to-be
attached patch.

[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-21 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

Uroš Bizjak  changed:

   What|Removed |Added

 Target|x86_64-*-linux-gnu  |x86
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |ubizjak at gmail dot com

--- Comment #4 from Uroš Bizjak  ---
(In reply to Andrew Pinski from comment #3)

> Looks like this is a latent target bug as that change should not effect RTL
> at all (well the beginning expansion to RTL will be changed).

Yes, it is target problem with overflow patterns. MINUS overflow patterns are
invalid and should be removed.

I have a patch in testing.

[Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu

2013-10-21 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58779

Andrew Pinski  changed:

   What|Removed |Added

 Target||x86_64-*-linux-gnu
  Component|rtl-optimization|target

--- Comment #3 from Andrew Pinski  ---
(In reply to Mikael Pettersson from comment #2)
> Started with r180109.  CC:ing author.

Looks like this is a latent target bug as that change should not effect RTL at
all (well the beginning expansion to RTL will be changed).