]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR rtl-optimization/122575] Fix mode on optimized IOR comparison
authorJeff Law <jlaw@ventanamicro.com>
Mon, 17 Nov 2025 17:40:46 +0000 (10:40 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 17 Nov 2025 17:50:06 +0000 (10:50 -0700)
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.

gcc/simplify-rtx.cc

index 2f7ad2de1d194e0474367b1ea738c3a689f718bc..86baeb06ad48819e001fffdab5208ca9336156d5 100644 (file)
@@ -6500,10 +6500,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;
        }