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 tree-optimization/103037] [11/12 Regression] Wrong code with -O2 since r11-6100-gd41b097350d3c5d0 Date: Wed, 23 Feb 2022 15:25:36 +0000 [thread overview] Message-ID: <bug-103037-4-1AJ2zrMdMK@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103037-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103037 --- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- More reduced testcase - the min() obfuscation is to avoid recognizing a MIN_EXPR before jump threading gets the chance to disrupt it. A GIMPLE unit testcase for PRE is difficult since we are not supporting SSA annotations (ranges) at the moment. static inline const unsigned short * min(unsigned short *d, const unsigned short *e) { return *e < *d ? e : d; } unsigned short __attribute__((noipa)) test(unsigned short arr, unsigned short val) { unsigned short tem = 1; unsigned short tem2 = *min(&arr, &tem); return tem2 / (arr ? arr : val); } int main() { if (test (2, 2) != 0) __builtin_abort(); return 0; } The IL for the reduced testcase before PRE is <bb 2> [local count: 1073741824]: if (arr_6(D) > 1) goto <bb 4>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 536870912]: # RANGE [0, 1] NONZERO 1 _1 = (int) arr_6(D); // (A) if (arr_6(D) != 0) goto <bb 4>; [20.00%] else goto <bb 5>; [80.00%] <bb 4> [local count: 536870913]: # RANGE [0, 1] NONZERO 1 # _17 = PHI <_1(3), 1(2)> # RANGE [1, 65535] NONZERO 65535 iftmp.0_9 = (int) arr_6(D); // (B) goto <bb 6>; [100.00%] <bb 5> [local count: 536870913]: # RANGE [0, 65535] NONZERO 65535 iftmp.0_8 = (int) val_7(D); <bb 6> [local count: 1073741824]: # RANGE [0, 65535] NONZERO 65535 # iftmp.0_3 = PHI <iftmp.0_9(4), iftmp.0_8(5)> # RANGE [0, 1] NONZERO 1 # _18 = PHI <_17(4), 0(5)> # RANGE [0, 1] NONZERO 1 _2 = _18 / iftmp.0_3; # RANGE [0, 1] NONZERO 1 _10 = (short unsigned int) _2; return _10; and the problematic value-numbering is iftmp.0_9 = _1 (0001) at (A) and (B). By design we may only use _available_ expressions during simplification but _1 is not available on the 4 -> 6 edge. That's working OK for the translation from 4 -> 6 but then we record a valueized expression into the ANTIC set of 4 which when further translated and simplified has the wrong representative inside.
next prev parent reply other threads:[~2022-02-23 15:25 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-02 7:17 [Bug tree-optimization/103037] New: [11/12 Regression] Wrong code with -O2 vsevolod.livinskij at frtk dot ru 2021-11-02 7:36 ` [Bug tree-optimization/103037] [11/12 Regression] Wrong code with -O2 since r11-6100-gd41b097350d3c5d0 marxin at gcc dot gnu.org 2021-11-02 7:52 ` pinskia at gcc dot gnu.org 2021-11-02 8:43 ` rguenth at gcc dot gnu.org 2021-11-02 8:51 ` jakub at gcc dot gnu.org 2021-11-02 9:08 ` jakub at gcc dot gnu.org 2021-11-02 14:18 ` rguenther at suse dot de 2021-11-03 10:08 ` rguenth at gcc dot gnu.org 2021-11-05 13:39 ` rguenth at gcc dot gnu.org 2022-02-23 15:25 ` rguenth at gcc dot gnu.org [this message] 2022-02-25 12:21 ` cvs-commit at gcc dot gnu.org 2022-02-25 12:21 ` [Bug tree-optimization/103037] [11 " rguenth at gcc dot gnu.org 2022-04-21 7:50 ` rguenth at gcc dot gnu.org 2023-05-29 10:05 ` jakub 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-103037-4-1AJ2zrMdMK@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: linkBe 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).