This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v3] Do not simplify "(and (reg) (const bit))" to if_then_else.
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: vogt at linux dot vnet dot ibm dot com, Bernd Schmidt <bschmidt at redhat dot com>, gcc-patches at gcc dot gnu dot org, Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>, Ulrich Weigand <Ulrich dot Weigand at de dot ibm dot com>
- Date: Sat, 3 Dec 2016 19:19:13 -0600
- Subject: Re: [PATCH v3] Do not simplify "(and (reg) (const bit))" to if_then_else.
- Authentication-results: sourceware.org; auth=none
- References: <20161031195610.GA3558@linux.vnet.ibm.com> <4c9dd4a4-9f4f-048c-67d5-8ace6bd6eb8c@redhat.com> <20161111111028.GA30873@linux.vnet.ibm.com> <20161121123647.GA22233@linux.vnet.ibm.com> <9044f460-61af-3680-4ac4-5ac9d7ead673@redhat.com> <20161201153008.GA28115@linux.vnet.ibm.com>
[ I did not see this patch before, sorry. ]
This causes the second half of PR78638.
On Thu, Dec 01, 2016 at 04:30:08PM +0100, Dominik Vogt wrote:
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -5600,6 +5600,18 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
> && OBJECT_P (SUBREG_REG (XEXP (x, 0)))))))
> {
> rtx cond, true_rtx, false_rtx;
> + unsigned HOST_WIDE_INT nz;
> +
> + /* If the operation is an AND wrapped in a SIGN_EXTEND or ZERO_EXTEND with
> + either operand being just a constant single bit value, do nothing since
> + IF_THEN_ELSE is likely to increase the expression's complexity. */
> + if (HWI_COMPUTABLE_MODE_P (mode)
> + && pow2p_hwi (nz = nonzero_bits (x, mode))
> + && ! ((code == SIGN_EXTEND || code == ZERO_EXTEND)
> + && GET_CODE (XEXP (x, 0)) == AND
> + && CONST_INT_P (XEXP (XEXP (x, 0), 0))
> + && UINTVAL (XEXP (XEXP (x, 0), 0)) == nz))
> + return x;
The code does not match the comment: the "!" should not be there. How
did it fix anything on s390 *with* that "!"? That does not make much
sense.
Segher