]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR rtl-optimization/122536] Fix guard against variable bit extracts in RTL simplifier
authorJeff Law <jlaw@ventanamicro.com>
Mon, 3 Nov 2025 19:46:23 +0000 (12:46 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 3 Nov 2025 19:46:23 +0000 (12:46 -0700)
While I haven't been able to reproduce the failure Sam reported, based on the
RTL checking failure point and the code in question it was pretty clear the
code that was supposed to guard against a variable bit extract was just
checking the wrong argument to verify it was a constant integer -- it missed a
level of XEXP object extraction.

I passed this patch along to Sam and he verified it fixes his kernel build.
I've bootstrapped and regression tested on x86_64.  Pushing to the trunk.

Pushing to the trunk.

PR rtl-optimization/122536
gcc/
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Fix
guard against variable bit extracts in recent change.

gcc/simplify-rtx.cc

index 989cf9c2c82fc39694011d2a8a17b209f807a727..53592d2a2f4d7c2df0b6254940bf3c0502d5b9fe 100644 (file)
@@ -3686,8 +3686,8 @@ simplify_context::simplify_binary_operation_1 (rtx_code code,
          && XEXP (op0, 1) == CONST1_RTX (mode)
          && XEXP (op1, 1) == CONST1_RTX (mode)
          /* Verify bit positions (for cases with variable bit position). */
-         && CONST_INT_P (XEXP (op0, 1))
-         && CONST_INT_P (XEXP (op1, 1)))
+         && CONST_INT_P (XEXP (XEXP (op0, 0), 1))
+         && CONST_INT_P (XEXP (XEXP (op1, 0), 1)))
        {
          unsigned HOST_WIDE_INT bitpos1 = INTVAL (XEXP (XEXP (op0, 0), 1));
          unsigned HOST_WIDE_INT bitpos2 = INTVAL (XEXP (XEXP (op1, 0), 1));
@@ -3718,7 +3718,7 @@ simplify_context::simplify_binary_operation_1 (rtx_code code,
          && XEXP (op0, 1) == CONST1_RTX (mode)
          && XEXP (op1, 1) == CONST0_RTX (mode)
          /* Verify bit position. */
-         && CONST_INT_P (XEXP (op0, 1)))
+         && CONST_INT_P (XEXP (XEXP (op0, 0), 1)))
        {
          unsigned HOST_WIDE_INT bitpos1 = INTVAL (XEXP (XEXP (op0, 0), 1));
          unsigned HOST_WIDE_INT mask