This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, PR 88253, combine] Prevent combine simplification to zero if side_effects_p
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: SenthilKumar dot Selvaraj at microchip dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 15 Dec 2018 07:34:02 -0600
- Subject: Re: [Patch, PR 88253, combine] Prevent combine simplification to zero if side_effects_p
- References: <87h8fgpipg.fsf@microchip.com>
Hi!
On Fri, Dec 14, 2018 at 09:21:26AM +0000, SenthilKumar.Selvaraj@microchip.com wrote:
> This patch fixes PR 88253 by preventing combine_simplify_rtx from
> folding an rtx with side_effects_p to const0_rtx.
> 2018-12-14 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
>
> PR 88253.c
> * combine.c (combine_simplify_rtx): Test for side-effects before
> substituting by zero.
>
> gcc/testsuite/ChangeLog:
>
> 2018-12-14 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
>
> * gcc.target/avr/pr88253.c: New test.
> diff --git gcc/combine.c gcc/combine.c
> index 7e611399f2c..e634e8f5a7e 100644
> --- gcc/combine.c
> +++ gcc/combine.c
> @@ -5978,6 +5978,7 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
> && known_eq (subreg_lowpart_offset (int_mode, int_op0_mode),
> SUBREG_BYTE (x))
> && HWI_COMPUTABLE_MODE_P (int_op0_mode)
> + && !side_effects_p (SUBREG_REG (x))
> && (nonzero_bits (SUBREG_REG (x), int_op0_mode)
> & GET_MODE_MASK (int_mode)) == 0)
> return CONST0_RTX (int_mode);
Please move the !side_effects_p test last (it is expensive). With that,
okay for trunk and backports to 8 and 7.
Thanks!
Segher