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/65407] Extra mask register move in gcc.target/i386/avx512f-kandnw-1.c
Date: Thu, 12 Mar 2015 17:43:00 -0000	[thread overview]
Message-ID: <bug-65407-4-A0J8wcaCgP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65407-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ra
             Target|                            |x86
                 CC|                            |hjl.tools at gmail dot com,
                   |                            |kyukhin at gcc dot gnu.org,
                   |                            |vmakarov at gcc dot gnu.org

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Happens in reload:

(insn 17 11 19 2 (parallel [
            (set (reg:HI 69 k0 [104])
                (and:HI (not:HI (reg:HI 69 k0 [orig:100 k1 ] [100]))
                    (reg:HI 70 k1 [orig:102 k2 ] [102])))
            (clobber (reg:CC 17 flags))
        ]) /ssd/uros/gcc-build/prev-gcc/include/avx512fintrin.h:9995 388
{kandnhi}
     (nil))
...
(insn 36 21 29 2 (set (reg:HI 71 k2 [104])
        (reg:HI 69 k0 [104]))
/ssd/uros/gcc-build/prev-gcc/include/avx512fintrin.h:10718 92 {*movhi_internal}
     (nil))
(insn 29 36 31 2 (set (reg:V16SF 21 xmm0 [109])
        (vec_merge:V16SF (plus:V16SF (reg:V16SF 23 xmm2 [orig:91 D.26753 ]
[91])
                (reg:V16SF 22 xmm1 [orig:90 D.26753 ] [90]))
            (reg:V16SF 21 xmm0 [orig:92 D.26753 ] [92])
            (reg:HI 71 k2 [104])))
/ssd/uros/gcc-build/prev-gcc/include/avx512fintrin.h:10718 1356
{*addv16sf3_mask}
     (nil))

The constraint for mask register in (insn 29) is Yk (so, k1 to k7) and reload
satisfies this by emitting input reload from k0 -> k2. Ideally, k2 should be
chosen as output register from (insn 17).
>From gcc-bugs-return-480219-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Mar 12 17:44:24 2015
Return-Path: <gcc-bugs-return-480219-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 58205 invoked by alias); 12 Mar 2015 17:44:24 -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 58147 invoked by uid 48); 12 Mar 2015 17:44:20 -0000
From: "uweigand at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65408] New: powerpc64 function argument passing may access invalid memory
Date: Thu, 12 Mar 2015 17:44: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: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: uweigand at gcc dot gnu.org
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 cc cf_gcctarget
Message-ID: <bug-65408-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-03/txt/msg01363.txt.bz2
Content-length: 1535

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

            Bug ID: 65408
           Summary: powerpc64 function argument passing may access invalid
                    memory
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: uweigand at gcc dot gnu.org
                CC: amodra at gcc dot gnu.org, bergner at gcc dot gnu.org,
                    meissner at gcc dot gnu.org
            Target: powerpc64-linux, powerpc64le-linux

The following simple test case:

struct test
{
  int x;
  int y;
  int z;
};

void func(struct test);

void foo(struct test *ptr)
{
  func(*ptr);
}

generates this code for "foo":
        ld 4,8(3)
        ld 3,0(3)
        bl func

Note how *16 bytes* of memory are accessed here.   This is wrong, since "struct
test" is only 12 bytes in size with 4-byte alignment, and if you have an array
of those, the last element may happen to reside just 12 bytes before a page
boundary, so accessing 16 bytes may in fact crash.

When using the -mstrict-align compiler option, we get instead:
        lwz 0,0(3)
        lwz 4,8(3)
        lwz 3,4(3)
        sldi 0,0,32
        or 3,3,0
        sldi 4,4,32
        bl func
which is less than optimal, but at least correct.

This bug seems to be present in all compiler versions I've tested (BE or LE),
modulo those that default to -mstrict-align (e.g. LE with -mtune=power7).


       reply	other threads:[~2015-03-12 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-65407-4@http.gcc.gnu.org/bugzilla/>
2015-03-12 17:43 ` ubizjak at gmail dot com [this message]
2015-03-27 15:13 ` vmakarov at gcc dot gnu.org
2015-03-27 18:13 ` 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-65407-4-A0J8wcaCgP@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).