public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/59390] New: presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
@ 2013-12-04 20:46 jtaylor.debian at googlemail dot com
  2013-12-05  7:10 ` [Bug target/59390] " ubizjak at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jtaylor.debian at googlemail dot com @ 2013-12-04 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59390
           Summary: presence of  __attribute__((target("fma")))
                    declaration breaks __builtin_fma
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jtaylor.debian at googlemail dot com

compiling this code leads to a compilation error on -O3:


#include "math.h"
void fun() __attribute__((target("fma")));

void 
other_fun(double *restrict out, double * restrict a, double * restrict b,
double * restrict c, int n)
{
    int i;
    for (i = 0; i < n; i++) {
        out[i] = fma(a[i], b[i], c[i]);
    }   
}

$ cc-4.9 fma.c -c -std=c99 -O3
fma.c: In function ‘other_fun’:
fma.c:9:21: error: ‘__builtin_ia32_vfmaddpd’ needs isa option -m32 -mfma4 -mfma
         out[i] = fma(a[i], b[i], c[i]);
                     ^

removing the attribute from the unused declaration fixes it, as does using
-fno-builtin or a lower optimization level.

$ gcc-4.9 -v
Using built-in specs.
COLLECT_GCC=/home/jtaylor/tmp/gcc-local/bin/../bin/gcc
COLLECT_LTO_WRAPPER=/home/jtaylor/tmp/gcc-local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/jtaylor/tmp/gcc/configure
--enable-languages=c,c++,fortran --enable-tls
--prefix=/home/jtaylor/tmp/gcc-local --with-gmp=/usr --with-mpfr=/usr
--with-mpc=/usr --with-cloog=/usr --with-ppl=/usr --with-isl=/usr
Thread model: posix
gcc version 4.9.0 20131204 (experimental) (GCC)

also affects gcc 4.8.1
>From gcc-bugs-return-436671-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Dec 04 20:59:14 2013
Return-Path: <gcc-bugs-return-436671-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23008 invoked by alias); 4 Dec 2013 20:59:14 -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 19393 invoked by uid 48); 4 Dec 2013 20:57:56 -0000
From: "octoploid at yandex dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/58251] -flto causes ICE lto1: internal compiler error: in splice_child_die, at dwarf2out.c:4706
Date: Wed, 04 Dec 2013 20:59: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: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: octoploid at yandex 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: cc
Message-ID: <bug-58251-4-04HyiDNy65@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58251-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58251-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-12/txt/msg00326.txt.bz2
Content-length: 604

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

Markus Trippelsdorf <octoploid at yandex dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |octoploid at yandex dot com

--- Comment #2 from Markus Trippelsdorf <octoploid at yandex dot com> ---
(In reply to David Kredba from comment #1)
> I can reproduce this with Gentoo gcc-4.8.2 and new KDE's kig package 4.11.4.
>
> How to debug this please?

http://gcc.gnu.org/wiki/A_guide_to_testcase_reduction


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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
@ 2013-12-05  7:10 ` ubizjak at gmail dot com
  2013-12-05 10:52 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ubizjak at gmail dot com @ 2013-12-05  7:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tmsriram at google dot com

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Adding CC.
>From gcc-bugs-return-436703-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Dec 05 07:11:14 2013
Return-Path: <gcc-bugs-return-436703-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21179 invoked by alias); 5 Dec 2013 07:11:14 -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 21151 invoked by uid 48); 5 Dec 2013 07:11:11 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/59385] gcc 4.9 fails to use fma with __attribute__((target("fma")))
Date: Thu, 05 Dec 2013 07:11: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:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail 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: cc
Message-ID: <bug-59385-4-wfxubL5jUG@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59385-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59385-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-12/txt/msg00358.txt.bz2
Content-length: 395

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tmsriram at google dot com

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
Adding CC.
>From gcc-bugs-return-436704-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Dec 05 08:07:06 2013
Return-Path: <gcc-bugs-return-436704-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17755 invoked by alias); 5 Dec 2013 08:07:05 -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 17722 invoked by uid 48); 5 Dec 2013 08:07:02 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/55125] segfault when declaration of the struct's array
Date: Thu, 05 Dec 2013 08:07:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.6.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
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_status resolution
Message-ID: <bug-55125-4-Pyt5D6Llty@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-55125-4@http.gcc.gnu.org/bugzilla/>
References: <bug-55125-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-12/txt/msg00359.txt.bz2
Content-length: 434

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Closing.


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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
  2013-12-05  7:10 ` [Bug target/59390] " ubizjak at gmail dot com
@ 2013-12-05 10:52 ` rguenth at gcc dot gnu.org
  2013-12-05 19:24 ` tmsriram at google dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-12-05 10:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-12-05
     Ever confirmed|0                           |1
      Known to fail|                            |4.7.3, 4.8.2, 4.9.0

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


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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
  2013-12-05  7:10 ` [Bug target/59390] " ubizjak at gmail dot com
  2013-12-05 10:52 ` rguenth at gcc dot gnu.org
@ 2013-12-05 19:24 ` tmsriram at google dot com
  2013-12-06  0:34 ` tmsriram at google dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tmsriram at google dot com @ 2013-12-05 19:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Sriraman Tallam <tmsriram at google dot com> ---
JFYI, I am seeing this issue even in gcc-4.7.


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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
                   ` (2 preceding siblings ...)
  2013-12-05 19:24 ` tmsriram at google dot com
@ 2013-12-06  0:34 ` tmsriram at google dot com
  2013-12-11 20:06 ` tmsriram at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tmsriram at google dot com @ 2013-12-06  0:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Sriraman Tallam <tmsriram at google dot com> ---
Here is the problem. GCC adds target-specific builtins on demand. The FMA
target-specific builtin __builtin_ia32_vfmaddpd gets added via this
declaration:

void fun() __attribute__((target("fma")));

Specifically, the builtin __builtin_ia32_vfmaddpd gets added when
ix86_add_new_builtins is called from ix86_valid_target_attribute_tree when
processing this target attribute.

Now, when the vectorizer is processing the builtin "__builtin_fma" in function
other_fn(), it checks to see if this function is vectorizable and calls
ix86_builtin_vectorized_function in i386.c. That returns the builtin stored
here:


   case BUILT_IN_FMA:
      if (out_mode == DFmode && in_mode == DFmode)
    {
      if (out_n == 2 && in_n == 2)
        return ix86_builtins[IX86_BUILTIN_VFMADDPD];
          ....

ix86_builtins[IX86_BUILTIN_VFMADDPD] would have contained NULL_TREE had the
builtin not been added by the previous target attribute. That is why the code
works if we remove the previous declaration.

The fix then is to not just return the builtin but to also check if the current
function's isa allows the use of the builtin. For instance, this patch would
solve the problem:

@@ -33977,7 +33977,13 @@ ix86_builtin_vectorized_function (tree fndecl, tre
       if (out_mode == DFmode && in_mode == DFmode)
     {
       if (out_n == 2 && in_n == 2)
-        return ix86_builtins[IX86_BUILTIN_VFMADDPD];
+        {
+          if (ix86_builtins_isa[IX86_BUILTIN_VFMADDPD].isa
+          & global_options.x_ix86_isa_flags)
+            return ix86_builtins[IX86_BUILTIN_VFMADDPD];
+          else
+        return NULL_TREE;
+        }


but there are many instances of this usage in ix86_builtin_vectorized_function.
I will make a patch to cover all these cases and send for review.


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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
                   ` (3 preceding siblings ...)
  2013-12-06  0:34 ` tmsriram at google dot com
@ 2013-12-11 20:06 ` tmsriram at gcc dot gnu.org
  2021-08-09  7:30 ` pinskia at gcc dot gnu.org
  2023-12-04  3:10 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: tmsriram at gcc dot gnu.org @ 2013-12-11 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from tmsriram at gcc dot gnu.org <tmsriram at gcc dot gnu.org> ---
Author: tmsriram
Date: Wed Dec 11 20:06:46 2013
New Revision: 205904

URL: http://gcc.gnu.org/viewcvs?rev=205904&root=gcc&view=rev
Log:
2013-12-11  Sriraman Tallam  <tmsriram@google.com>

    PR target/59390
    * config/i386/i386.c (get_builtin): New function.
    (ix86_builtin_vectorized_function): Replace all instances of
    ix86_builtins[...] with get_builtin(...).
    (ix86_builtin_reciprocal): Ditto.

    PR target/59390
    * gcc.target/i386/pr59390.c: New test.
    * gcc.target/i386/pr59390_1.c: New test.
    * gcc.target/i386/pr59390_2.c: New test.

Tested boot-strap on all languages and test parity on x86_64 and with -m32.



Added:
    trunk/gcc/testsuite/gcc.target/i386/pr59390.c
    trunk/gcc/testsuite/gcc.target/i386/pr59390_1.c
    trunk/gcc/testsuite/gcc.target/i386/pr59390_2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
                   ` (4 preceding siblings ...)
  2013-12-11 20:06 ` tmsriram at gcc dot gnu.org
@ 2021-08-09  7:30 ` pinskia at gcc dot gnu.org
  2023-12-04  3:10 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-09  7:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |4.9.0
         Resolution|---                         |FIXED
           Keywords|                            |ice-on-valid-code,
                   |                            |rejects-valid

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 4.9.0

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

* [Bug target/59390] presence of  __attribute__((target("fma"))) declaration breaks __builtin_fma
  2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
                   ` (5 preceding siblings ...)
  2021-08-09  7:30 ` pinskia at gcc dot gnu.org
@ 2023-12-04  3:10 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-04  3:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |d.g.gorbachev at gmail dot com

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 56536 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-12-04  3:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-04 20:46 [Bug target/59390] New: presence of __attribute__((target("fma"))) declaration breaks __builtin_fma jtaylor.debian at googlemail dot com
2013-12-05  7:10 ` [Bug target/59390] " ubizjak at gmail dot com
2013-12-05 10:52 ` rguenth at gcc dot gnu.org
2013-12-05 19:24 ` tmsriram at google dot com
2013-12-06  0:34 ` tmsriram at google dot com
2013-12-11 20:06 ` tmsriram at gcc dot gnu.org
2021-08-09  7:30 ` pinskia at gcc dot gnu.org
2023-12-04  3:10 ` pinskia 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).