https://gcc.gnu.org/g:f8fb076af5bfab687e5941ea6c9efd44ad0ae140
commit r17-6667-gf8fb076af5bfab687e5941ea6c9efd44ad0ae140 Author: Jeff Law <[email protected]> Date: Tue Nov 24 22:00:23 2026 -0700 Fix WORD_REGISTER_OPERATIONS issue noted by Sashiko in recent change This fixes a Sashiko issue with my last commit (that had slipped through my internal LLM review)... Basically for a WORD_REGISTER_OPERATIONS target when we check nonzero_bits, we want to pass in the wider mode; other code in simplify-rtx is already going this and I'll need to adjust another in-flight patch to include this hunk. Bootstrapped and regression tested on x86 and aarch. Pushing to the trunk. gcc/ * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Use WORD_MODE on WORD_REGISTER_OPERATIONS targets when the given mode is less than a word. Diff: --- gcc/simplify-rtx.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index 7eed2525dbf4..9c836d8dde09 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -4537,9 +4537,17 @@ simplify_context::simplify_binary_operation_1 (rtx_code code, { rtx x = i ? op1 : op0; rtx y = i ? op0 : op1; + + /* When WORD_REGISTER_OPERATIONS is true, we need to know the + nonzero bits in WORD_MODE rather than MODE. */ + scalar_int_mode tmode = as_a <scalar_int_mode> (int_mode); + if (WORD_REGISTER_OPERATIONS + && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD) + tmode = word_mode; + if (GET_CODE (x) == XOR && XEXP (x, 1) == CONST1_RTX (mode) - && (nonzero_bits (y, int_mode) & ~HOST_WIDE_INT_1U) == 0) + && (nonzero_bits (y, tmode) & ~HOST_WIDE_INT_1U) == 0) return simplify_gen_binary (AND, mode, simplify_gen_unary (NOT, mode, XEXP (x, 0),
