On 8/30/26 8:26 PM, wangjue wrote:
From: juewang <[email protected]>

Handle conditional arithmetic wrapped in a sign or zero extension when
the unchanged value is known to have the same extension.  Query the
promoted lowpart directly instead of searching for its definition.

gcc/ChangeLog:

        * ifcvt.cc (noce_cond_arith_operation): New function.
        (noce_operand_known_extended_p): New function.
        (noce_try_cond_arith): Handle arithmetic operations wrapped in an
        extension.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/pr122769.c: Add the branch cost and restrict the
        test to compatible optimization options.
        * gcc.target/riscv/zicond-conditional-add-extend.c: New test.
Thanks.  Please make sure to note how you've tested patches.  For a patch to the generic part of the compiler the patch must be bootstrapped and regression tested on a major target (x86_64 and aarch64 are the most common).

I took care of throwing this into my tester overnight.  While the nightly runs aren't done, it did pass x86_64 and aarch64 with no regressions.

However, it did flag a failure on riscv64-elf.  In particular gcc.target/riscv/pr123322.c fails.  It's pretty obvious that the test in question just needed to be updated for the improved code generation.   I've fixed that and pushed your patch to the trunk.

Thanks!

jeff

Reply via email to