Re: [PATCH] tree-optimization: Handle variable trip count XOR in final value replacement [PR112104]

"H.J. Lu" <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CAMe9rOoOh8CKNO0V8CNG0Jjf=3TLmvu1n+9zON0GZW3hfe2bnQ@mail.gmail.com>
On Tue, Aug 11, 2026 at 5:43 PM Eikansh Gupta
<[email protected]> wrote:
>
> analyze_and_compute_bitop_with_inv_effect replaces a loop that repeatedly
> applies a bitwise op with a loop-invariant operand by its closed form.  The
> BIT_XOR case only handled a constant trip count; for a variable count it
> bailed out, leaving loops like "for (i=0;i<n;i++) j ^= 1;" in place.
>
> Mask the invariant with that runtime parity to handle a variable count.
> A constant count folds as before.
>
>         PR tree-optimization/112104
>
> gcc/ChangeLog:
>
>         * tree-scalar-evolution.cc (analyze_and_compute_bitop_with_inv_effect):
>         Handle BIT_XOR_EXPR with a variable trip count.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/pr105735-1.c: Bump final value replacement count
>         from 8 to 9.
>         * gcc.target/i386/pr105735-3.c: Likewise.
>         * gcc.dg/tree-ssa/pr112104-1.c: New test.
>         * gcc.dg/tree-ssa/pr112104-2.c: New test.
>

This caused:

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

-- 
H.J.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.