public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bauhaus at futureapps dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/53590] New: new compiler generates both SISD and SIMD instructions for parallel operations of a "pure" function
Date: Wed, 06 Jun 2012 13:14:00 -0000	[thread overview]
Message-ID: <bug-53590-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             Bug #: 53590
           Summary: new compiler generates both SISD and SIMD instructions
                    for parallel operations of a "pure" function
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: ada
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bauhaus@futureapps.de


The Ada compiler of 4.8.0 on Intel will either
- produce 2 DIVSD and also 1 DIVPD (redundance), or
- produce 2 DIVSD (no measurable parallelism)
for the following function f that divides two pairs
of 64 bit FPT types and returns one pair.
The expectation is just 1 DIVPD.
Other versions of the Ada compiler, and the C compiler,
and the C++ compiler of the same version produce
1 DIVPD instruction, as expected.

The line marked --! below switches between the two cases
listed above.

package Autovect is

   pragma Pure (Autovect);

   type Fpt is new Long_Float;

   type Vec is array (0 .. 1) of Fpt;
   --pragma Machine_Attribute (Vec, "vector_type");  --!
   --pragma Machine_Attribute (Vec, "may_alias");  

   function F (X0, X1, Y0, Y1 : Fpt) return Vec;

private
   pragma Assert (Fpt'Size = 64);
   pragma Assert (Vec'Alignment = 16);
end Autovect;

package body Autovect is

   function F (X0, X1, Y0, Y1 : Fpt) return Vec is
   begin
      return (X0 / Y0, X1 / Y1);
   end F;

end Autovect;

Result:

0000000000000010 <autovect__f>:
  10:    66 0f 28 e8              movapd %xmm0,%xmm5
  14:    66 0f 28 f2              movapd %xmm2,%xmm6
  18:    66 0f 14 e9              unpcklpd %xmm1,%xmm5
  1c:    66 0f 14 f3              unpcklpd %xmm3,%xmm6
  20:    f2 0f 5e c2              divsd  %xmm2,%xmm0
  24:    66 0f 28 e5              movapd %xmm5,%xmm4
  28:    66 0f 5e e6              divpd  %xmm6,%xmm4
  2c:    f2 0f 5e cb              divsd  %xmm3,%xmm1
  30:    66 0f 29 64 24 e8        movapd %xmm4,-0x18(%rsp)
  36:    f2 0f 10 44 24 e8        movsd  -0x18(%rsp),%xmm0
  3c:    f2 0f 10 4c 24 f0        movsd  -0x10(%rsp),%xmm1
  42:    c3                       retq   
  43:    66 66 66 66 2e 0f 1f     data32 data32 data32 nopw
%cs:0x0(%rax,%rax,1)
  4a:    84 00 00 00 00 00 

With "vector_type" machine attribute:

0000000000000010 <autovect__f>:
  10:    f2 0f 5e c2              divsd  %xmm2,%xmm0
  14:    f2 0f 5e cb              divsd  %xmm3,%xmm1
  18:    66 0f 14 c1              unpcklpd %xmm1,%xmm0
  1c:    c3                       retq   
  1d:    0f 1f 00                 nopl   (%rax)


gnatchop -r -w autovect.ada && gnatmake -gnatwa -W -O3 -fno-inline
-fomit-frame-pointer -msse3 -march=core2 -gnatp -gnata -v autovect.adb
splitting autovect.ada into:
   autovect.ads
   autovect.adb

GNATMAKE 4.8.0 20120525 (experimental)
Copyright (C) 1995-2012, Free Software Foundation, Inc.
  "autovect.ali" being checked ...
  -> "autovect.ads" time stamp mismatch
gcc -c -gnatwa -W -O3 -fno-inline -fomit-frame-pointer -msse3 -march=core2
-gnatp -gnata autovect.adb
End of compilation

Linux newnews 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012
x86_64 x86_64 x86_64 GNU/Linux

Intel E6750

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/bauhaus/mine/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/bauhaus/src/gcc/trunk/configure
--prefix=/home/bauhaus/mine --disable-nls --disable-libstdcxx-pch
--enable-languages=c,ada,c++
Thread model: posix
gcc version 4.8.0 20120525 (experimental) (GCC)


             reply	other threads:[~2012-06-06 13:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06 13:14 bauhaus at futureapps dot de [this message]
2012-06-06 13:29 ` [Bug ada/53590] " bauhaus at futureapps dot de
2012-06-10  8:42 ` ebotcazou at gcc dot gnu.org
2012-06-11  9:53 ` rguenth at gcc dot gnu.org
2012-06-11 10:09 ` georggcc at googlemail dot com
2012-06-11 10:31 ` georggcc at googlemail dot com
2012-06-11 10:39 ` [Bug ada/53590] compiler fails to generate SIMD instruction for FP division ebotcazou at gcc dot gnu.org
2012-06-11 10:59 ` georggcc at googlemail dot com
2012-06-12 16:54 ` ebotcazou at gcc dot gnu.org
2012-06-13 17:12 ` [Bug middle-end/53590] " georggcc at googlemail dot com
2012-06-15  9:22 ` ebotcazou at gcc dot gnu.org
2012-06-15 10:00 ` ebotcazou at gcc dot gnu.org
2012-06-15 14:54 ` georggcc at googlemail dot com
2012-06-16 11:06 ` ebotcazou at gcc dot gnu.org
2014-07-10 10:39 ` ebotcazou at gcc dot gnu.org
2014-07-10 10:41 ` ebotcazou at gcc dot gnu.org

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-53590-4@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).