This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix combine's simplify_comparison (PR rtl-optimization/51023)
On 11/09/11 17:24, Jakub Jelinek wrote:
> --- gcc/combine.c.jj 2011-11-08 23:35:12.000000000 +0100
> +++ gcc/combine.c 2011-11-09 10:06:27.207333364 +0100
> @@ -11397,13 +11397,20 @@ simplify_comparison (enum rtx_code code,
> later on, and then we wouldn't know whether to sign- or
> zero-extend. */
> mode = GET_MODE (XEXP (op0, 0));
> - if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT
> + if (GET_MODE_CLASS (mode) == MODE_INT
> && ! unsigned_comparison_p
> - && val_signbit_known_clear_p (mode, const_op)
> - && have_insn_for (COMPARE, mode))
> + && HWI_COMPUTABLE_MODE_P (mode))
> {
> - op0 = XEXP (op0, 0);
> - continue;
> + HOST_WIDE_INT c = trunc_int_for_mode (const_op, mode);
> + /* Don't do this if the sign bit of MODE or any
> + higher bit is set in CONST_OP. */
> + if (c == const_op
> + && c >= 0
> + && have_insn_for (COMPARE, mode))
> + {
> + op0 = XEXP (op0, 0);
> + continue;
> + }
> }
Yes, I think I prefer this.
Bernd