[Bug middle-end/125708] Missed optimization: division by (2 - bool) emits idivl instead of shift/select

liuhongt at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 10 03:32:40 GMT 2026


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

--- Comment #4 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
(In reply to Drea Pinski from comment #1)
> Given a range that only has 2 values we could "change" a/b into `b==value1 ?
> a/value1 : a/value2` during the last forwprop via match.
> If we want to do it for powers of 2 only that might be a good idea.


It sounds like a different optimization which speculatively optimize for a/b or
a%b to runtime check if b is powerof2?


More information about the Gcc-bugs mailing list