public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/67317] [x86] Silly code generation for _addcarry_u32/_addcarry_u64
Date: Thu, 27 Aug 2015 08:53:00 -0000	[thread overview]
Message-ID: <bug-67317-4-ws3rXr6KoE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-67317-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67317

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ubizjak at gmail dot com

--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 36258
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36258&action=edit
Proposed patch

This patch changes expanders of carry-handling builtins to use
addqi3_cconly_overflow and canonicalizes carry hanling insn to what combine can
process:

(define_insn "addcarry<mode>"
  [(set (reg:CCC FLAGS_REG)
        (compare:CCC
          (plus:SWI48
            (plus:SWI48
              (match_operator:SWI48 4 "ix86_carry_flag_operator"
               [(match_operand 3 "flags_reg_operand") (const_int 0)])
              (match_operand:SWI48 1 "nonimmediate_operand" "%0"))
            (match_operand:SWI48 2 "nonimmediate_operand" "rm"))
          (match_dup 1)))
   (set (match_operand:SWI48 0 "register_operand" "=r")
        (plus:SWI48 (plus:SWI48 (match_op_dup 4
                                 [(match_dup 3) (const_int 0)])
                                (match_dup 1))
                    (match_dup 2)))]
  "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
  "adc{<imodesuffix>}\t{%2, %0|%0, %2}"
  [(set_attr "type" "alu")
   (set_attr "use_carry" "1")
   (set_attr "pent_pair" "pu")
   (set_attr "mode" "<MODE>")])

and

(define_insn "subborrow<mode>"
  [(set (reg:CCC FLAGS_REG)
        (compare:CCC
          (match_operand:SWI48 1 "nonimmediate_operand" "0")
          (plus:SWI48
            (match_operator:SWI48 4 "ix86_carry_flag_operator"
             [(match_operand 3 "flags_reg_operand") (const_int 0)])
            (match_operand:SWI48 2 "nonimmediate_operand" "rm"))))
   (set (match_operand:SWI48 0 "register_operand" "=r")
        (minus:SWI48 (minus:SWI48 (match_dup 1)
                                  (match_op_dup 4
                                   [(match_dup 3) (const_int 0)]))
                     (match_dup 2)))]
  "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
  "sbb{<imodesuffix>}\t{%2, %0|%0, %2}"
  [(set_attr "type" "alu")
   (set_attr "use_carry" "1")
   (set_attr "pent_pair" "pu")
   (set_attr "mode" "<MODE>")])

The patch also rewrites expander to fix a bug, where carry-clobbering insns
were emitted inside carry-flag def-use chain.

For the testcase, patched gcc generates:

testcarry_u64:
        addq    %rdi, %rdx
        adcq    %rsi, %rcx
        movq    %rdx, %rax
        xorq    %rcx, %rax
        ret
>From gcc-bugs-return-495714-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Aug 27 09:03:29 2015
Return-Path: <gcc-bugs-return-495714-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 99696 invoked by alias); 27 Aug 2015 09:03: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 99601 invoked by uid 48); 27 Aug 2015 09:03:25 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/67317] [x86] Silly code generation for _addcarry_u32/_addcarry_u64
Date: Thu, 27 Aug 2015 09:03: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: 5.2.0
X-Bugzilla-Keywords: missed-optimization
X-Bugzilla-Severity: minor
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ubizjak at gmail dot com
X-Bugzilla-Target-Milestone: 5.3
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cf_gcctarget cc target_milestone
Message-ID: <bug-67317-4-GlAZRhVnYn@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67317-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67317-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: 2015-08/txt/msg01856.txt.bz2
Content-length: 403

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67317

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|x86_64-*-*                  |x86
                 CC|uros at gcc dot gnu.org            |
   Target Milestone|---                         |5.3
>From gcc-bugs-return-495715-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Aug 27 09:29:35 2015
Return-Path: <gcc-bugs-return-495715-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 86690 invoked by alias); 27 Aug 2015 09:29:35 -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 86601 invoked by uid 48); 27 Aug 2015 09:29:30 -0000
From: "rogero at howzatt dot demon.co.uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/67357] -Wodr warnings from types in anonymous namespace
Date: Thu, 27 Aug 2015 09:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 5.2.0
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rogero at howzatt dot demon.co.uk
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
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-67357-4-Qc0VzHGEAW@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67357-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67357-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: 2015-08/txt/msg01857.txt.bz2
Content-length: 1536

https://gcc.gnu.org/bugzilla/show_bug.cgi?idg357

--- Comment #3 from Roger Orr <rogero at howzatt dot demon.co.uk> ---
The following code block also gives an ODR violation with the same versions of
gcc; in this case only a *single* translation unit is involved.

$ cat test.cxx
#include <memory>

template<typename T>
class D : public T {
    using mfn_t = void (D::*)();
    std::tuple<mfn_t> data{&D::foo};
public:
    void foo() {
        std::get<0>(data);
    }
};

namespace {
    struct S {};
}

int main() {
    D<S> obj;
}

$ /opt/gcc-5.2.0/bin/g++ -flto -Wodr -std=c++11 test.cxx
test.cxx:5:32: warning: type 'struct mfn_t' violates one definition rule
[-Wodr]
     using mfn_t = void (D::*)();
                                ^
/opt/gcc-5.2.0/include/c++/5.2.0/tuple:764:21: note: a different type is
defined in another translation unit
       typedef _Head type;
                     ^
test.cxx:5:32: note: the first difference of corresponding definitions is field
'__pfn'
     using mfn_t = void (D::*)();
                                ^
test.cxx:5:32: note: a field of same name but different type is defined in
another translation unit
lto1: note: type mismatch in parameter 1
test.cxx:4:20: note: type 'struct D' defined in anonymous namespace can not
match type 'struct D'
 class D : public T {
                    ^
test.cxx:4:7: note: the incompatible type defined in anonymous namespace in
another translation unit
 class D : public T {
       ^

(Giving the anonymous namespace a name removes the warnings.)


  parent reply	other threads:[~2015-08-27  8:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-22  4:59 [Bug inline-asm/67317] New: " myriachan at gmail dot com
2015-08-22  6:14 ` [Bug inline-asm/67317] " pinskia at gcc dot gnu.org
2015-08-25  8:24 ` rguenth at gcc dot gnu.org
2015-08-25 11:10 ` [Bug target/67317] " glisse at gcc dot gnu.org
2015-08-25 12:58 ` segher at gcc dot gnu.org
2015-08-25 16:48 ` ubizjak at gmail dot com
2015-08-25 19:26 ` segher at gcc dot gnu.org
2015-08-27  8:53 ` ubizjak at gmail dot com [this message]
2015-08-27 18:30 ` uros at gcc dot gnu.org
2015-09-02 15:07 ` uros at gcc dot gnu.org
2015-09-02 15:08 ` ubizjak at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-67317-4-ws3rXr6KoE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).