On 7/14/2026 1:11 AM, Jim Lin wrote:
The splitter matching (x >= 1 ? 2^n : 0) lowered it to
tmp = (x > 1); result = tmp << n, emitting any_gt instead of any_ge.
At x == 1 the original yields 2^n but the split yields 0, a
miscompile.  Emit any_ge to reproduce the matched comparison, as the
sibling GE/GEU splitters already do.

gcc/ChangeLog:

        * config/riscv/zicond.md: Emit any_ge instead of any_gt in the
        GE/GEU if-then-else splitter.
I'm embarrassed by that one, thanks for spotting it and fixing it. OK for the trunk.

Interestingly enough I've got a TODO to throw all our patterns into the LLMs to catch this kind of goof.  It seemed like this would be a good pattern to throw in now to see if the LLM discovers a problem. The LLM I generally prefer did flag the pattern as problematical, but kept focusing on adjusting the constant in the output rather than the much more obvious code iterator mismatch.  So good that it flagged the pattern, but it could have been much better.

Thanks again!


jeff

Reply via email to