public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu
@ 2013-10-18  6:44 su at cs dot ucdavis.edu
  2013-10-18  6:53 ` [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-10-18  6:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58779
           Summary: wrong code at -O1 on x86_64-linux-gnu
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk (as well as gcc 4.7 and 4.8) miscompiles the following
code on x86_64-linux at -O1 in both 32-bit and 64-bit modes. 

This is a regression from 4.6.x. 

It disappears with -fno-if-conversion. 


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131017 (experimental) [trunk revision 203789] (GCC) 
$ 
$ gcc-trunk -O0 small.c; a.out
$ 
$ gcc-trunk -O1 small.c; a.out
Aborted (core dumped)
$ 
$ gcc-trunk -O1 -fno-if-conversion small.c; a.out
$ 
$ gcc-4.8 -O1 small.c; a.out
Aborted (core dumped)
$
$ gcc-4.7 -O1 small.c; a.out
Aborted (core dumped)
$ 
$ gcc-4.6 -O1 small.c; a.out
$ 


--------------------------------


int a, c;

int
main ()
{
  int e = -1;
  short d = (c <= 0) ^ e;
  if ((unsigned int) a - (a || d) <= (unsigned int) a)
    __builtin_abort(); 
  return 0;
}


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

* [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2013-10-18  6:53 ` pinskia at gcc dot gnu.org
  2013-10-18  8:16 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-10-18  6:53 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|---                         |4.7.4
            Summary|wrong code at -O1 on        |[4.7/4.8/4.9 Regression]
                   |x86_64-linux-gnu            |wrong code at -O1 on
                   |                            |x86_64-linux-gnu


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

* [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-10-18  6:53 ` [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] " pinskia at gcc dot gnu.org
@ 2013-10-18  8:16 ` rguenth at gcc dot gnu.org
  2013-10-20 21:08 ` mikpelinux at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-18  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-18
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.


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

* [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-10-18  6:53 ` [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] " pinskia at gcc dot gnu.org
  2013-10-18  8:16 ` rguenth at gcc dot gnu.org
@ 2013-10-20 21:08 ` mikpelinux at gmail dot com
  2013-10-21  6:52 ` [Bug target/58779] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mikpelinux at gmail dot com @ 2013-10-20 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org,
                   |                            |mikpelinux at gmail dot com

--- Comment #2 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Started with r180109.  CC:ing author.

The code generation difference for this test case at r180109 is:

--- pr58779-r180108.s   2013-10-20 22:44:38.935370903 +0200
+++ pr58779-r180109.s   2013-10-20 22:40:11.576301229 +0200
@@ -8,11 +8,10 @@
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        movl    a(%rip), %eax
-       leal    -1(%rax), %edx
-       cmpl    %edx, %eax
-       jb      .L2
+       addl    $-1, %eax
+       jb      .L3
        call    abort
-.L2:
+.L3:
        movl    $0, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8

But these two code fragments set the flags differently: according to gdb the
older one sets CF AF IF at the point of the jb, while the newer one sets PF SF
IF.  Since jb checks CF, the newer code fails.


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-10-20 21:08 ` mikpelinux at gmail dot com
@ 2013-10-21  6:52 ` pinskia at gcc dot gnu.org
  2013-10-22  6:10 ` ubizjak at gmail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-10-21  6:52 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-linux-gnu
          Component|rtl-optimization            |target

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(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).


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2013-10-21  6:52 ` [Bug target/58779] " pinskia at gcc dot gnu.org
@ 2013-10-22  6:10 ` ubizjak at gmail dot com
  2013-10-22  7:08 ` ubizjak at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2013-10-22  6:10 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> 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 <ubizjak at gmail dot com> ---
(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.
>From gcc-bugs-return-432428-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 06:40:29 2013
Return-Path: <gcc-bugs-return-432428-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29506 invoked by alias); 22 Oct 2013 06:40:29 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 29449 invoked by uid 55); 22 Oct 2013 06:40:23 -0000
From: "zeccav at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58813] SIGSEGV in show_locus at error.c:310
Date: Tue, 22 Oct 2013 06:40:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords: error-recovery, ice-on-invalid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: zeccav at gmail dot com
X-Bugzilla-Status: REOPENED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58813-4-Yrl0iUvFi7@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58813-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58813-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01572.txt.bz2
Content-length: 347

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX813

--- Comment #6 from Vittorio Zecca <zeccav at gmail dot com> ---
I found that
export MALLOC_PERTURB_%6
produces a quiet NaN. I'll use this one in my .bashrc
It seems to me that the earlier symptom of malfunctioning
is in symbol.c:5001 " dummies = sym->formal;" where sym points the wrong way.


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2013-10-22  6:10 ` ubizjak at gmail dot com
@ 2013-10-22  7:08 ` ubizjak at gmail dot com
  2013-10-22 18:36 ` uros at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2013-10-22  7:08 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 9847 bytes --]

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

--- Comment #5 from Uroš Bizjak <ubizjak at gmail dot com> ---
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.
>From gcc-bugs-return-432430-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 07:09:31 2013
Return-Path: <gcc-bugs-return-432430-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19234 invoked by alias); 22 Oct 2013 07:09:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 19179 invoked by uid 48); 22 Oct 2013 07:09:28 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
Date: Tue, 22 Oct 2013 07:09:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ubizjak at gmail dot com
X-Bugzilla-Target-Milestone: 4.7.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-58779-4-PrthPMGrAC@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58779-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58779-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01574.txt.bz2
Content-length: 289

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

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

Patch in testing.
>From gcc-bugs-return-432431-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 07:45:49 2013
Return-Path: <gcc-bugs-return-432431-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10958 invoked by alias); 22 Oct 2013 07:45:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 10930 invoked by uid 48); 22 Oct 2013 07:45:44 -0000
From: "dougkwan at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58838] New: mullw sets condition code incorrectly.
Date: Tue, 22 Oct 2013 07:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dougkwan at google dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-58838-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01575.txt.bz2
Content-length: 3174

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX838

            Bug ID: 58838
           Summary: mullw sets condition code incorrectly.
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dougkwan at google dot com

It was observed in 4.7 and trunk that the Power backend generated bad code
involving condition setting mullw.  Below is a test case for the problem:

-----
#include <cassert>
#include <cstdlib>
#include <vector>

struct b88 {
 char data[88];
};

namespace {

inline int int_size(const std::vector<b88>& v) {
 return v.size();
}

}

int __attribute__ ((noinline))
foo(const std::vector<b88>& v) {
 if (int_size(v) > 0) {
   return atoi("1");
 }
 return 0;
}

int main() {
 std::vector<b88> v;
 v.push_back(b88());
 assert(foo(v) != 0);
 return 0;
}
----

The above test failed with gcc 4.7 and trunk for target powerpc64-linux-gnu

We seem to be fine getting out of the middle-end of gcc-4.7:

;; Function int foo(const std::vector<b88>&) (_Z3fooRKSt6vectorI3b88SaIS0_EE,
funcdef_noG3, decl_uid‘36, cgraph_uid\x102)

int foo(const std::vector<b88>&) (const struct vector & v)
{
 int _1;
 struct b88 * _4;
 struct b88 * _5;
 long int _6;
 long int _7;
 long int _8;
 long int _9;
 int _10;
 long int _11;
 int _12;

 <bb 2>:
 _4 = MEM[(const struct vector *)v_3(D)];
 _5 = MEM[(const struct vector *)v_3(D) + 8B];
 _6 = (long int) _5;
 _7 = (long int) _4;
 _8 = _6 - _7;
 _9 = _8 /[ex] 88;
 _10 = (int) _9;
 if (_10 > 0)
   goto <bb 3>;
 else
   goto <bb 4>;

 <bb 3>:
 _11 = strtol ("1", 0B, 10);
 _12 = (int) _11;

 <bb 4>:
 # _1 = PHI <_12(3), 0(2)>
 return _1;

}

RTL expansion looks correct, gcc expands "_8 /[ex] 88;" into shift and
multiplication.

(_8 >> 3) * 0x2e8ba2e8ba2e8ba3.

Since we know that the _8 is a multiple of 88, we can do this.
0x2e8ba2e8ba2e8ba3 is the multiplicative-inverse of 11 in Z{2^64}.


But the selected PPC instruction is bad:

  0x10000b80 <._Z3fooRKSt6vectorI3b88SaIS0_EE>:        lis     r9,11915
  0x10000b84 <._Z3fooRKSt6vectorI3b88SaIS0_EE+4>:      ld      r8,8(r3)
  0x10000b88 <._Z3fooRKSt6vectorI3b88SaIS0_EE+8>:      ld      r10,0(r3)
  0x10000b8c <._Z3fooRKSt6vectorI3b88SaIS0_EE+12>:     ori     r9,r9,41704
  0x10000b90 <._Z3fooRKSt6vectorI3b88SaIS0_EE+16>:     rldicr  r9,r9,32,31
  0x10000b94 <._Z3fooRKSt6vectorI3b88SaIS0_EE+20>:     subf    r10,r10,r8
  0x10000b98 <._Z3fooRKSt6vectorI3b88SaIS0_EE+24>:     oris    r9,r9,47662
  0x10000b9c <._Z3fooRKSt6vectorI3b88SaIS0_EE+28>:     sradi   r10,r10,3
  0x10000ba0 <._Z3fooRKSt6vectorI3b88SaIS0_EE+32>:     ori     r9,r9,35747
  0x10000ba4 <._Z3fooRKSt6vectorI3b88SaIS0_EE+36>:     mullw.  r8,r10,r9
<================ note the "dot"
  0x10000ba8 <._Z3fooRKSt6vectorI3b88SaIS0_EE+40>:     ble     0x10000bf0
<._Z3fooRKSt6vectorI3b88SaIS0_EE+112>

mullw correctly computes the lower 32-bits of  "_9 = _8 /[ex] 88;" but it sets
the condition code incorrectly, since signed-comparison is done in 64 bits.
Instead there should be sign extension, ie.

mullw  r8,r10,r9
extsw. r8,r8


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2013-10-22  7:08 ` ubizjak at gmail dot com
@ 2013-10-22 18:36 ` uros at gcc dot gnu.org
  2013-10-22 18:38 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu.org @ 2013-10-22 18:36 UTC (permalink / raw)
  To: gcc-bugs

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) <case GTU, case LEU>:
    Remove CCCmode handling.
    <case LTU>: Return 'c' suffix for CCCmode.
    <case GEU>: Return 'nc' suffix for CCCmode.
    (ix86_cc_mode) <case GTU, case LEU>: Do not generate overflow checks.
    * config/i386/i386.md (*sub<mode>3_cconly_overflow): Remove.
    (*sub<mode>3_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


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (6 preceding siblings ...)
  2013-10-22 18:36 ` uros at gcc dot gnu.org
@ 2013-10-22 18:38 ` ubizjak at gmail dot com
  2013-10-26  6:02 ` uros at gcc dot gnu.org
  2013-10-26  6:09 ` uros at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2013-10-22 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Uroš Bizjak <ubizjak at gmail dot com> ---
Fixed on trunk sofar.
>From gcc-bugs-return-432484-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 18:38:22 2013
Return-Path: <gcc-bugs-return-432484-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14997 invoked by alias); 22 Oct 2013 18:38:22 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 14944 invoked by uid 48); 22 Oct 2013 18:38:19 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
Date: Tue, 22 Oct 2013 18:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ubizjak at gmail dot com
X-Bugzilla-Target-Milestone: 4.7.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_file_loc
Message-ID: <bug-58779-4-Lm39PRvbSf@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58779-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58779-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01628.txt.bz2
Content-length: 588

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

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

--- Comment #8 from Uroš Bizjak <ubizjak at gmail dot com> ---
Patch at [1].

[1] http://gcc.gnu.org/ml/gcc-patches/2013-10/msg01826.html
>From gcc-bugs-return-432486-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 19:39:05 2013
Return-Path: <gcc-bugs-return-432486-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16707 invoked by alias); 22 Oct 2013 19:39:04 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16658 invoked by uid 48); 22 Oct 2013 19:39:00 -0000
From: "q1 at oxyba dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/58815] Casting/Conversion operator for std::decimal not supported
Date: Tue, 22 Oct 2013 19:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.7.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: q1 at oxyba dot de
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58815-4-ifBVdkmQy4@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58815-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58815-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01630.txt.bz2
Content-length: 314

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX815

--- Comment #14 from ulf <q1 at oxyba dot de> ---
i am happy with the explicit operator in std::decimal for now. however sooner
or later there will be another one who puzzels over other issues (traits,
limits, and all the functions that dont know std::decimal).


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (7 preceding siblings ...)
  2013-10-22 18:38 ` ubizjak at gmail dot com
@ 2013-10-26  6:02 ` uros at gcc dot gnu.org
  2013-10-26  6:09 ` uros at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu.org @ 2013-10-26  6:02 UTC (permalink / raw)
  To: gcc-bugs

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  <ubizjak@gmail.com>

    PR target/58779
    * config/i386/i386.c (put_condition_code) <case GTU, case LEU>:
    Remove CCCmode handling.
    <case LTU>: Return 'c' suffix for CCCmode.
    <case GEU>: Return 'nc' suffix for CCCmode.
    (ix86_cc_mode) <case GTU, case LEU>: Do not generate overflow checks.
    * config/i386/i386.md (*sub<mode>3_cconly_overflow): Remove.
    (*sub<mode>3_cc_overflow): Ditto.
    (*subsi3_zext_cc_overflow): Ditto.

    Backport from mainline
    2013-10-19  Uros Bizjak  <ubizjak@gmail.com>

    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  <ubizjak@gmail.com>

    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


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

* [Bug target/58779] [4.7/4.8/4.9 Regression] wrong code at -O1 on x86_64-linux-gnu
  2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (8 preceding siblings ...)
  2013-10-26  6:02 ` uros at gcc dot gnu.org
@ 2013-10-26  6:09 ` uros at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu.org @ 2013-10-26  6:09 UTC (permalink / raw)
  To: gcc-bugs

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  <ubizjak@gmail.com>

    PR target/58779
    * config/i386/i386.c (put_condition_code) <case GTU, case LEU>:
    Remove CCCmode handling.
    <case LTU>: Return 'c' suffix for CCCmode.
    <case GEU>: Return 'nc' suffix for CCCmode.
    (ix86_cc_mode) <case GTU, case LEU>: Do not generate overflow checks.
    * config/i386/i386.md (*sub<mode>3_cconly_overflow): Remove.
    (*sub<mode>3_cc_overflow): Ditto.
    (*subsi3_zext_cc_overflow): Ditto.

    Backport from mainline
    2013-10-19  Uros Bizjak  <ubizjak@gmail.com>

    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  <ubizjak@gmail.com>

    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


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

end of thread, other threads:[~2013-10-26  6:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18  6:44 [Bug rtl-optimization/58779] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
2013-10-18  6:53 ` [Bug rtl-optimization/58779] [4.7/4.8/4.9 Regression] " pinskia at gcc dot gnu.org
2013-10-18  8:16 ` rguenth at gcc dot gnu.org
2013-10-20 21:08 ` mikpelinux at gmail dot com
2013-10-21  6:52 ` [Bug target/58779] " pinskia at gcc dot gnu.org
2013-10-22  6:10 ` ubizjak at gmail dot com
2013-10-22  7:08 ` ubizjak at gmail dot com
2013-10-22 18:36 ` uros at gcc dot gnu.org
2013-10-22 18:38 ` ubizjak at gmail dot com
2013-10-26  6:02 ` uros at gcc dot gnu.org
2013-10-26  6:09 ` uros at gcc dot gnu.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).