public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/106187] armhf: Miscompilation at O2 level (O0 / O1 are working)
Date: Tue, 19 Jul 2022 07:27:46 +0000	[thread overview]
Message-ID: <bug-106187-4-tnv5m065YC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106187-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #28 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Earnshaw from comment #26)
> git bisect points to commit r11-9688 resolving the issue.  Before that
> commit the ivopts pass generates:
> 
>   ivtmp.761_217 = (unsigned int) &au;
>   _222 = &bu + 4;
>   ivtmp.767_220 = (unsigned int) _222;
>   _225 = (unsigned int) &au;
>   _228 = _225 + 16;
> 
>   <bb 9> [local count: 858993457]:
>   # prephitmp_136 = PHI <pretmp_120(10), 1073741824(8)>
>   # prephitmp_32 = PHI <pretmp_18(10), 2147483648(8)>
>   # ivtmp.761_278 = PHI <ivtmp.761_216(10), ivtmp.761_217(8)>
>   # ivtmp.767_218 = PHI <ivtmp.767_219(10), ivtmp.767_220(8)>
>   _16 = prephitmp_32 ^ prephitmp_136;
>   _223 = (void *) ivtmp.761_278;
>   MEM[(unsigned int *)_223] = _16;
>   ivtmp.761_216 = ivtmp.761_278 + 4;
>   if (ivtmp.761_216 != _228)
>     goto <bb 10>; [75.00%]
>   else
>     goto <bb 11>; [25.00%]
> 
>   <bb 10> [local count: 644245086]:
>   _230 = (void *) ivtmp.761_216;
>   pretmp_120 = MEM[(unsigned int *)_230];
>   _229 = (void *) ivtmp.767_218;
>   pretmp_18 = MEM[(unsigned int *)_229];
>   ivtmp.767_219 = ivtmp.767_218 + 4;
>   goto <bb 9>; [100.00%]
> 
> And once that patch is applied we get:
> 
>   ivtmp.761_217 = (unsigned int) &au;
>   ivtmp.766_220 = (unsigned int) &bu;
>   _223 = (unsigned int) &au;
>   _225 = _223 + 16;
> 
>   <bb 9> [local count: 858993457]:
>   # prephitmp_136 = PHI <pretmp_120(10), 1073741824(8)>
>   # prephitmp_32 = PHI <pretmp_18(10), 2147483648(8)>
>   # ivtmp.761_278 = PHI <ivtmp.761_216(10), ivtmp.761_217(8)>
>   # ivtmp.766_218 = PHI <ivtmp.766_219(10), ivtmp.766_220(8)>
>   _16 = prephitmp_32 ^ prephitmp_136;
>   _222 = (void *) ivtmp.761_278;
>   MEM[(unsigned int *)_222] = _16;
>   ivtmp.761_216 = ivtmp.761_278 + 4;
>   if (ivtmp.761_216 != _225)
>     goto <bb 10>; [75.00%]
>   else
>     goto <bb 11>; [25.00%]
> 
> The main difference being that in the 'bad' code we start with &bu + 4,
> while in the good code we start with &bu.
> 
> I'm afraid I don't know enough about this code to take this further.  Richi?

There's no functional difference, you omitted BB9 after the patch which
for me looks like

  <bb 10> [local count: 644245086]:
  # PT = { D.22767 }
  _228 = (voidD.73 *) ivtmp.741_281;
  [t.ii:2167:17] pretmp_155 = MEM[(unsigned intD.11 *)_228];
  [t.ii:2167:26] ivtmp.746_28 = ivtmp.746_299 + 4;
  # PT = { D.22768 }
  _227 = (voidD.73 *) ivtmp.746_28;
  [t.ii:2167:26] pretmp_183 = MEM[(unsigned intD.11 *)_227];
  goto <bb 9>; [100.00%]

so we changed from post-increment to pre-increment of 4 - the accesses
happen to the same memory location.

I'm dumping with -alias-uid-lineno and alias info looks fine to me here.

It might very well be that the change above triggers a bug elsewhere.  Does
reverting the "fixing" revision make the issue appear on trunk as well?

The code at RTL expansion time looks reasonable (also from an aliasing POV),
if -fno-strict-aliasing fixes it, does -fno-schedule-insn{,2} also?

  parent reply	other threads:[~2022-07-19  7:27 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 16:23 [Bug c++/106187] New: armhf: Miscompilation with -O2 mathieu.malaterre at gmail dot com
2022-07-04 16:37 ` [Bug c++/106187] " mathieu.malaterre at gmail dot com
2022-07-04 16:37 ` mathieu.malaterre at gmail dot com
2022-07-04 16:42 ` [Bug c++/106187] armhf: Miscompilation at all optimization levels mathieu.malaterre at gmail dot com
2022-07-04 20:19 ` pinskia at gcc dot gnu.org
2022-07-04 20:22 ` pinskia at gcc dot gnu.org
2022-07-05  7:18 ` [Bug target/106187] " mathieu.malaterre at gmail dot com
2022-07-05  7:46 ` [Bug target/106187] armhf: Miscompilation at O2 level (O0 / O1 are working) jan.wassenberg at gmail dot com
2022-07-05  8:00 ` mathieu.malaterre at gmail dot com
2022-07-07  7:50 ` mathieu.malaterre at gmail dot com
2022-07-07  8:00 ` mathieu.malaterre at gmail dot com
2022-07-07  9:38 ` rearnsha at gcc dot gnu.org
2022-07-08  9:01 ` mathieu.malaterre at gmail dot com
2022-07-08  9:01 ` mathieu.malaterre at gmail dot com
2022-07-08  9:03 ` mathieu.malaterre at gmail dot com
2022-07-08 13:50 ` rearnsha at gcc dot gnu.org
2022-07-08 13:59 ` malat at debian dot org
2022-07-08 14:16 ` rearnsha at gcc dot gnu.org
2022-07-08 14:18 ` malat at debian dot org
2022-07-08 14:51 ` rearnsha at gcc dot gnu.org
2022-07-08 15:03 ` malat at debian dot org
2022-07-08 17:24 ` rearnsha at gcc dot gnu.org
2022-07-08 17:31 ` rearnsha at gcc dot gnu.org
2022-07-08 19:27 ` jan.wassenberg at gmail dot com
2022-07-14 13:03 ` rearnsha at gcc dot gnu.org
2022-07-14 13:18 ` rearnsha at gcc dot gnu.org
2022-07-14 16:09 ` pinskia at gcc dot gnu.org
2022-07-18 15:45 ` rearnsha at gcc dot gnu.org
2022-07-18 15:48 ` rearnsha at gcc dot gnu.org
2022-07-19  7:27 ` rguenth at gcc dot gnu.org [this message]
2022-07-19  9:00 ` rearnsha at gcc dot gnu.org
2022-07-19  9:13 ` rguenth at gcc dot gnu.org
2022-07-21  9:25 ` rearnsha at gcc dot gnu.org
2022-07-22 12:52 ` rearnsha at gcc dot gnu.org
2022-07-22 13:24 ` rearnsha at gcc dot gnu.org
2022-07-25  6:12 ` rguenth at gcc dot gnu.org
2022-07-25  9:44 ` rearnsha at gcc dot gnu.org
2022-07-25  9:50 ` rguenther at suse dot de
2022-07-25  9:59 ` rearnsha at gcc dot gnu.org
2022-07-25 10:24 ` rguenth at gcc dot gnu.org
2022-07-25 10:26 ` [Bug rtl-optimization/106187] " rguenth at gcc dot gnu.org
2022-07-25 10:33 ` rearnsha at gcc dot gnu.org
2022-07-25 10:42 ` rguenth at gcc dot gnu.org
2022-07-25 10:48 ` rearnsha at gcc dot gnu.org
2022-07-25 11:03 ` rguenther at suse dot de
2022-07-25 11:05 ` rguenth at gcc dot gnu.org
2022-07-25 13:04 ` rearnsha at gcc dot gnu.org
2022-07-25 14:45 ` rguenther at suse dot de
2022-07-27 13:35 ` rearnsha at gcc dot gnu.org
2022-07-28 16:51 ` rearnsha at gcc dot gnu.org
2022-08-03  9:07 ` cvs-commit at gcc dot gnu.org
2022-08-03  9:16 ` rearnsha at gcc dot gnu.org
2022-08-10  7:06 ` malat at debian dot org
2022-08-10  7:11 ` pinskia at gcc dot gnu.org
2022-09-02  9:28 ` malat at debian dot org
2022-09-02 12:30 ` cvs-commit at gcc dot gnu.org
2022-09-02 12:32 ` rearnsha at gcc dot gnu.org
2022-09-02 14:07 ` cvs-commit at gcc dot gnu.org
2022-09-27 15:28 ` malat at debian dot org
2022-09-27 15:54 ` rearnsha at gcc dot gnu.org
2024-01-20 17:20 ` pinskia 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-106187-4-tnv5m065YC@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).