public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/111231] [12/13/14 regression] armhf: Miscompilation with -O2/-fno-exceptions level (-fno-tree-vectorize is working)
Date: Fri, 22 Mar 2024 18:02:14 +0000	[thread overview]
Message-ID: <bug-111231-4-wMjE56MU0r@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111231-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #19 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
This is another problem with (I suspect) incorrect aliasing information.  If I
compile with -fno-strict-aliasing, I get

  88:   f4432a1f        vst1.8  {d18-d19}, [r3 :64]     // {>E}   SP+96/16
  8c:   f4420a1f        vst1.8  {d16-d17}, [r2 :64]     // {>A}   SP+32/16
  90:   e893000f        ldm     r3, {r0, r1, r2, r3}    // {<E}   SP+96/16
  94:   e884000f        stm     r4, {r0, r1, r2, r3}    // {>G}   SP+128/16
  98:   eddd0b20        vldr    d16, [sp, #128] ; 0x80  // {<G.l} SP+128/8
  9c:   eddd1b22        vldr    d17, [sp, #136] ; 0x88  // {<G.h} SP+136/8
  a0:   e88c000f        stm     ip, {r0, r1, r2, r3}    // {>B}   SP+48/16
  a4:   e28dc040        add     ip, sp, #64     ; 0x40
  a8:   e885000f        stm     r5, {r0, r1, r2, r3}    // {>F}   SP+112/16
  ac:   f2d80570        vshl.s16        q8, q8, #8
  b0:   f3f503e0        vneg.s16        q8, q8
  b4:   edcd0b20        vstr    d16, [sp, #128] ; 0x80  // {>G.l} SP+128/8
  b8:   edcd1b22        vstr    d17, [sp, #136] ; 0x88  // {>G.h} SP+136/8
  bc:   e894000f        ldm     r4, {r0, r1, r2, r3}    // {<G}   SP+128/16
  c0:   e88c000f        stm     ip, {r0, r1, r2, r3}    // {>C}   SP+64/16
  c4:   e28dc050        add     ip, sp, #80     ; 0x50
  c8:   e88c000f        stm     ip, {r0, r1, r2, r3}    // {>D}   SP+80/16
  cc:   e885000f        stm     r5, {r0, r1, r2, r3}    // {>F}   SP+112/16

I've annotated each memory access with its stack address and labeled each
16-byte slot from A to G.

With -fstrict-aliasing this becomes:

  88:   f4420a1f        vst1.8  {d16-d17}, [r2 :64]     // {>A}   SP+32/16
  8c:   eddd0b20        vldr    d16, [sp, #128] ; 0x80  // {<G.l} SP+128/8     
!
  90:   eddd1b22        vldr    d17, [sp, #136] ; 0x88  // {<G.h} SP+136/8     
!
  94:   f4432a1f        vst1.8  {d18-d19}, [r3 :64]     // {>E}   SP+96/16
  98:   e893000f        ldm     r3, {r0, r1, r2, r3}    // {<E}   SP+96/16
  9c:   e88c000f        stm     ip, {r0, r1, r2, r3}    // {>B}   SP+48/16
  a0:   e28dc040        add     ip, sp, #64     ; 0x40
  a4:   f2d80570        vshl.s16        q8, q8, #8
  a8:   e884000f        stm     r4, {r0, r1, r2, r3}    // {>G}   SP+128/16    
!
  ac:   e885000f        stm     r5, {r0, r1, r2, r3}    // {>F}   SP+112/16
  b0:   f3f503e0        vneg.s16        q8, q8
  b4:   edcd0b20        vstr    d16, [sp, #128] ; 0x80  // {>G.l} SP+128/8
  b8:   edcd1b22        vstr    d17, [sp, #136] ; 0x88  // {>G.h} SP+136/8
  bc:   e894000f        ldm     r4, {r0, r1, r2, r3}    // {<G}   SP+128/16
  c0:   e88c000f        stm     ip, {r0, r1, r2, r3}    // {>C}   SP+64/16
  c4:   e28dc050        add     ip, sp, #80     ; 0x50
  c8:   e88c000f        stm     ip, {r0, r1, r2, r3}    // {>D}   SP+80/16
  cc:   e885000f        stm     r5, {r0, r1, r2, r3}    // {>F}   SP+112/16

And we see that the initial store to G has been moved after the reads from it. 
I'm still digging, but it may be pertinent that the reads have been split into
two separate instructions; perhaps when the split was done the alias sets
weren't copied correctly.

  parent reply	other threads:[~2024-03-22 18:02 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  6:47 [Bug target/111231] New: armhf: Miscompilation at O2 level malat at debian dot org
2023-08-30  6:49 ` [Bug target/111231] " malat at debian dot org
2023-08-30  6:51 ` malat at debian dot org
2023-08-30  7:18 ` [Bug target/111231] armhf: Miscompilation at O2 level (O1 is working) malat at debian dot org
2023-08-31  6:49 ` malat at debian dot org
2023-09-05 16:24 ` malat at debian dot org
2023-09-14 13:52 ` [Bug target/111231] [13/14 Regression] " malat at debian dot org
2023-09-15  8:06 ` [Bug target/111231] armhf: Miscompilation with -O2/-fno-exceptions level (-O2 " malat at debian dot org
2023-09-26  6:29 ` malat at debian dot org
2023-09-26  6:29 ` malat at debian dot org
2023-09-26  6:31 ` malat at debian dot org
2023-09-26  6:32 ` malat at debian dot org
2023-09-26  9:00 ` xry111 at gcc dot gnu.org
2023-10-06  6:16 ` [Bug target/111231] armhf: Miscompilation with -O2/-fno-exceptions level (-fno-tree-vectorize " malat at debian dot org
2023-10-06  6:21 ` malat at debian dot org
2023-10-06  6:47 ` malat at debian dot org
2023-12-15  7:33 ` malat at debian dot org
2024-03-17  2:44 ` [Bug target/111231] [12/13/14 regression] " sjames at gcc dot gnu.org
2024-03-17  2:46 ` sjames at gcc dot gnu.org
2024-03-22 13:39 ` law at gcc dot gnu.org
2024-03-22 18:02 ` rearnsha at gcc dot gnu.org [this message]
2024-03-25 12:46 ` rguenth at gcc dot gnu.org
2024-04-11 14:13 ` rearnsha at gcc dot gnu.org
2024-04-11 14:28 ` rearnsha at gcc dot gnu.org
2024-04-11 14:29 ` rearnsha at gcc dot gnu.org
2024-04-11 14:41 ` rearnsha at gcc dot gnu.org
2024-04-11 18:25 ` pinskia at gcc dot gnu.org
2024-04-12  6:17 ` rguenth at gcc dot gnu.org
2024-04-12 10:08 ` rearnsha at gcc dot gnu.org
2024-04-12 10:40 ` rearnsha at gcc dot gnu.org
2024-04-12 10:51 ` rguenth at gcc dot gnu.org
2024-04-12 13:10 ` rearnsha at gcc dot gnu.org
2024-04-15  6:46 ` rguenth at gcc dot gnu.org
2024-04-15 14:47 ` rearnsha at gcc dot gnu.org
2024-04-16  6:46 ` rguenth at gcc dot gnu.org
2024-04-16  6:57 ` rguenth at gcc dot gnu.org
2024-04-16  9:59 ` rearnsha at gcc dot gnu.org
2024-04-16 10:34 ` rguenther at suse dot de

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