[Bug debug/106746] [13 Regression] '-fcompare-debug' failure (length) with -O2 -fsched2-use-superblocks since r13-2041-g6624ad73064de241

hjl.tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 1 17:01:50 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106746

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |richard.sandiford at arm dot com,
                   |                            |roger at nextmovesoftware dot com,
                   |                            |segher at kernel dot crashing.org

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
Revert

diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index fa20665bb01..7d09bf7103d 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -1615,6 +1639,24 @@ simplify_context::simplify_unary_operation_1 (rtx_code
co
de, machine_mode mode,
            }
        }

+      /* We can canonicalize SIGN_EXTEND (op) as ZERO_EXTEND (op) when
+         we know the sign bit of OP must be clear.  */
+      if (val_signbit_known_clear_p (GET_MODE (op),
+                                    nonzero_bits (op, GET_MODE (op))))
+       return simplify_gen_unary (ZERO_EXTEND, mode, op, GET_MODE (op));
+
+      /* (sign_extend:DI (subreg:SI (ctz:DI ...))) is (ctz:DI ...).  */
+      if (GET_CODE (op) == SUBREG
+         && subreg_lowpart_p (op)
+         && GET_MODE (SUBREG_REG (op)) == mode
+         && is_a <scalar_int_mode> (mode, &int_mode)
+         && is_a <scalar_int_mode> (GET_MODE (op), &op_mode)
+         && GET_MODE_PRECISION (int_mode) <= HOST_BITS_PER_WIDE_INT
+         && GET_MODE_PRECISION (op_mode) < GET_MODE_PRECISION (int_mode)
+         && (nonzero_bits (SUBREG_REG (op), mode)
+             & ~(GET_MODE_MASK (op_mode) >> 1)) == 0)
+       return SUBREG_REG (op);
+
 #if defined(POINTERS_EXTEND_UNSIGNED)
       /* As we do not know which address space the pointer is referring to,
         we can do this only if the target does not support different pointer

fixes the failure.


More information about the Gcc-bugs mailing list