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/109483] Unoptimal uncprop with assembler flag output Date: Wed, 12 Apr 2023 10:47:40 +0000 [thread overview] Message-ID: <bug-109483-4-NvEEXLksHQ@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109483-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109483 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2023-04-12 Summary|Unoptimal jump threading |Unoptimal uncprop with |with assembler flag output |assembler flag output Ever confirmed|0 |1 Component|middle-end |tree-optimization --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- We expand from __asm__ __volatile__("int3" : "=@ccz" success_4); if (success_4 != 0) goto <bb 4>; [66.00%] else goto <bb 5>; [34.00%] ;; succ: 5 ;; 4 ;; basic block 4, loop depth 0 ;; pred: 3 ;; 2 __asm__ __volatile__("" : : : "memory"); ;; succ: 5 ;; basic block 5, loop depth 0 ;; pred: 3 ;; 4 # _1 = PHI <success_4(3), 1(4)> return _1; and it's not PHI-opt "getting in the way" but instead RTL expansion placing the edge 3->4 copy of 'success_4' before the conditional branch rather than to a new BB. I suppose if we'd split critical edges that would fix it (at the expense of some extra blocks and unconditional jumps). Note that clang seems to propagate the constant equivalence which we instead un-propagate. With -fdisable-tree-uncprop1 you'll get the expected code: foo: .LFB0: .cfi_startproc cmpl $-1, %edi je .L8 .L2: movl $1, %eax ret .p2align 4,,10 .p2align 3 .L8: xorl %eax, %eax #APP # 6 "t.c" 1 int3 # 0 "" 2 #NO_APP je .L2 ret what uncprop doesn't understand is that copying success requires to materialize it (it's just in CC), that's the reason it prefers that over a zero (because zero also needs materializing). And the RTL pipeline is not good enough in scheduling/sinking a CC consumer across another CC consumer it seems (or even realizing the result is constant on the only needed edge). It might be possible to just special-case (bool) ASM defs in uncprop, but that would be a heuristic. Not sure if we can portably identify CC mode constraints.
next prev parent reply other threads:[~2023-04-12 10:47 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-12 8:54 [Bug rtl-optimization/109483] New: Unoptimal jump threading " ubizjak at gmail dot com 2023-04-12 8:59 ` [Bug middle-end/109483] " pinskia at gcc dot gnu.org 2023-04-12 10:47 ` rguenth at gcc dot gnu.org [this message] 2023-04-12 10:48 ` [Bug tree-optimization/109483] Unoptimal uncprop " rguenth at gcc dot gnu.org 2023-04-12 14:40 ` ubizjak at gmail dot com 2023-04-12 19:43 ` 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-109483-4-NvEEXLksHQ@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).