[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] [PR rtl-optimization/122575] Fix mode on optimized IOR comparison

Jeff Law law@gcc.gnu.org
Mon Nov 17 21:09:40 GMT 2025


https://gcc.gnu.org/g:b9f8770053cc6769dc72a3539349e98a5b756ddb

commit b9f8770053cc6769dc72a3539349e98a5b756ddb
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Mon Nov 17 10:40:46 2025 -0700

    [PR rtl-optimization/122575] Fix mode on optimized IOR comparison
    
    As Andrew P recognized, we were using the wrong mode when simplifying certain
    equality tests like (eq (ior (ne x 0 (y)).  Sam took Andrew's suggestion and
    verified it fixed the problem he was stumbling over.
    
    So even though I haven't recreated the problem, I'm reasonably confident we've
    got the right fix.  I've bootstrapped and regression tested on x86.
    
            PR rtl-optimization/122575
    gcc/
            * simplify-rtx.cc (simplify_context::simplify_relational_operation_1):
            Use correct mode for simplified IOR expression inside equality
            conditional.
    
    (cherry picked from commit 2e1d74b27283b5c20b0e1611c358dbf4e62db54f)

Diff:
---
 gcc/simplify-rtx.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 1b32f0137568..a9091add76ef 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -6379,10 +6379,10 @@ simplify_context::simplify_relational_operation_1 (rtx_code code,
 	  /* only enters if op1 is 0 */
 	  /* Verify IOR operand is NE */
 	  && GET_CODE (XEXP (op0, 0)) == NE
-	  /* Verfiy second NE operand is 0 */
+	  /* Verify second NE operand is 0 */
 	  && XEXP (XEXP (op0, 0), 1) == CONST0_RTX (mode))
 	{
-	  rtx t = gen_rtx_IOR (mode, XEXP (XEXP (op0, 0), 0), XEXP (op0, 1));
+	  rtx t = gen_rtx_IOR (cmp_mode, XEXP (XEXP (op0, 0), 0), XEXP (op0, 1));
 	  t = gen_rtx_fmt_ee (code, mode, t, CONST0_RTX (mode));
 	  return t;
 	}


More information about the Gcc-cvs mailing list