https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93504
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:50adb5bb87d434467cf8d41b561a649db2473543 commit r17-411-g50adb5bb87d434467cf8d41b561a649db2473543 Author: Jeff Law <[email protected]> Date: Fri May 8 11:19:02 2026 -0600 [RISC-V][PR tree-optimization/93504] Handle (X & C) | ((X^Y) & ~C) -> X ^ ( Y & ~C) in simplify-rtx This is a trivial generalization of existing simplify-rtx code. Essentially the code in question was handling IOR, but not XOR. I'm keeping the bz open as this probably should have been cleaned up before getting into RTL. The net is something like this: > #define N 0x202 > #define OP ^ > > unsigned f(unsigned a, unsigned b) > { > unsigned t = a OP b; > unsigned t1 = t&N; > unsigned t2 = a&~N; > return t1 | t2; > } > Originally compiled into: xor a1,a0,a1 andi a1,a1,514 andi a0,a0,-515 or a0,a1,a0 ret After it compiles into: andi a1,a1,514 xor a0,a1,a0 ret Bootstrapped and regression tested on x86, aarch64 and various targets in qemu. Also tested on the usual embedded targets. PR tree-optimization/93504 gcc/ * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Generalize existing code for (X & C) | ((X|Y) & ~C) to handle (X & C) | ((X^Y) & ~C) as well. gcc/testsuite * gcc.target/riscv/pr93504.c: New test.
