public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112884] New: Missing optimization: fold a%2==0 ? a/2*2 : 0 to a%2==0 ? a : 0
@ 2023-12-06 16:47 xxs_chy at outlook dot com
  2023-12-06 18:41 ` [Bug tree-optimization/112884] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: xxs_chy at outlook dot com @ 2023-12-06 16:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112884
           Summary: Missing optimization: fold a%2==0 ? a/2*2 : 0 to
                    a%2==0 ? a : 0
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xxs_chy at outlook dot com
  Target Milestone: ---

Godbolt example: https://godbolt.org/z/Ec1ax79r8

For the select arm "a / 2 * 2" in:

unsigned src(unsigned a) {
    return a % 2 == 0 ? (a / 2 * 2) : 0;
}

it's equivalent to "a", so the program could be folded to:

unsigned tgt(unsigned a) {
    return a % 2 == 0 ? a : 0;
}

Both GCC and LLVM missed such optimization in select arms.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-07  8:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06 16:47 [Bug tree-optimization/112884] New: Missing optimization: fold a%2==0 ? a/2*2 : 0 to a%2==0 ? a : 0 xxs_chy at outlook dot com
2023-12-06 18:41 ` [Bug tree-optimization/112884] " pinskia at gcc dot gnu.org
2023-12-07  8:10 ` rguenth at gcc dot gnu.org
2023-12-07  8:26 ` pinskia at gcc dot gnu.org

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).