public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103088] [12 regression] 500.perlbench from spec 2017 fails since r12-4698 Date: Fri, 19 Nov 2021 16:11:18 +0000 [thread overview] Message-ID: <bug-103088-4-AgscOA7JhB@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103088-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103088 --- Comment #19 from Aldy Hernandez <aldyh at gcc dot gnu.org> --- Ughh, I was nerd sniped. Couldn't let it go ;-). The problem is this construct in Perl_do_ncmp: if (lnv < rnv) return -1; if (lnv > rnv) return 1; if (lnv == rnv) return 0; return 2; These are all doubles. The code is depending on a pair of values that are neither <, >, nor ==, being a NAN. For -ffast-math with unsafe optimizations we end up inling Perl_do_ncmp into pp_ge(): SETs(boolSV( (SvIOK_notUV(left) && SvIOK_notUV(right)) ? (SvIVX(left) >= SvIVX(right)) : ( (do_ncmp(left, right) & 2) == 0) )); but in doing so we destroy the 3 separate conditionals. At one point we're making decisions based on <= on the 35->38 edge: struct OP * Perl_pp_ge (): ... <bb 35> [local count: 590686791]: # iftmp.547_110 = PHI <iftmp.547_107(33), iftmp.547_108(34)> if (iftmp.546_109 > iftmp.547_110) goto <bb 23>; [1.04%] else goto <bb 38>; [98.96%] <snip> <snip> <bb 38> [local count: 644407314]: <bb 39> [local count: 953267993]: # iftmp.532_21 = PHI <&PL_sv_yes(38), &PL_sv_no(37)> MEM[(struct SV * *)sp_27 + -8B] = iftmp.532_21; PL_stack_sp = sp_30; PL_op.534_19 = PL_op; _38 = PL_op.534_19->op_next; <bb 40> [local count: 1073741826]: # _20 = PHI <_29(5), _38(39)> return _20; For -fno-unsafe-math-optimizations we avoid inlining Perl_no_ncmp, which keeps the conditionals. So it looks like we inline the NAN checking code in unsafe mode and the threader ends can make decisions on the return value for pp_ge(). As I said, the threads are correct. If anyone is curious, you can see what's going on by tagging Perl_do_ncmp() with __attribute__((optimize("O3", "fast-math", "no-unsafe-math-optimizations"))) and seeing the final pp_ge() output with the munged conditionals versus the pristine code in the output for Perl_do_ncmp. I think we can keep this PR closed. Don't use -ffast-math unless followed by -fno-unsafe-math-optimizations.
next prev parent reply other threads:[~2021-11-19 16:11 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-04 20:45 [Bug other/103088] New: " seurer at gcc dot gnu.org 2021-11-05 7:25 ` [Bug tree-optimization/103088] " rguenth at gcc dot gnu.org 2021-11-05 11:26 ` marxin at gcc dot gnu.org 2021-11-05 13:35 ` rguenth at gcc dot gnu.org 2021-11-05 14:19 ` seurer at gcc dot gnu.org 2021-11-17 15:28 ` tnfchris at gcc dot gnu.org 2021-11-17 17:48 ` aldyh at gcc dot gnu.org 2021-11-17 17:53 ` tnfchris at gcc dot gnu.org 2021-11-17 18:58 ` seurer at gcc dot gnu.org 2021-11-18 16:35 ` aldyh at gcc dot gnu.org 2021-11-18 16:45 ` tnfchris at gcc dot gnu.org 2021-11-18 19:13 ` aldyh at gcc dot gnu.org 2021-11-19 7:06 ` rguenther at suse dot de 2021-11-19 8:10 ` tnfchris at gcc dot gnu.org 2021-11-19 8:14 ` rguenth at gcc dot gnu.org 2021-11-19 10:09 ` aldyh at gcc dot gnu.org 2021-11-19 11:40 ` marxin at gcc dot gnu.org 2021-11-19 11:47 ` aldyh at gcc dot gnu.org 2021-11-19 11:58 ` tnfchris at gcc dot gnu.org 2021-11-19 12:27 ` marxin at gcc dot gnu.org 2021-11-19 12:33 ` tnfchris at gcc dot gnu.org 2021-11-19 16:11 ` aldyh at gcc dot gnu.org [this message] 2021-11-19 16:14 ` aldyh at gcc dot gnu.org 2021-11-21 19:37 ` aldyh at gcc dot gnu.org 2021-11-22 7:37 ` rguenther at suse dot de 2021-11-23 7:38 ` tnfchris at gcc dot gnu.org 2021-11-29 16:35 ` segher at gcc dot gnu.org 2024-05-02 21:31 ` 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-103088-4-AgscOA7JhB@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).