From e01f223f28d94ececee29b8048434361de5cd40c Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Mon, 19 Dec 2016 09:51:11 +0000 Subject: [PATCH] combine: Omit redundant AND in change_zero_ext. This is another micro-optimisation in change_zero_ext. If an (and (lshiftrt ... (N)) (M)) generated by change_zero_ext is equivalent to just (lshiftrt ... (N)) (because the AND constant selects the N rightmost bits of the result), strip off the AND. gcc/ChangeLog: 2016-12-19 Dominik Vogt * combine.c (change_zero_ext): Skip generation of redundant AND. From-SVN: r243792 --- gcc/ChangeLog | 4 ++++ gcc/combine.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57a1578caa3..3622483545c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2016-12-19 Dominik Vogt + + * combine.c (change_zero_ext): Skip generation of redundant AND. + 2016-12-19 Krister Walfridsson * config/netbsd.h (LINK_EH_SPEC): Define. diff --git a/gcc/combine.c b/gcc/combine.c index 473ffc4a132..e74ff4c20a1 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11289,8 +11289,13 @@ change_zero_ext (rtx pat) else continue; - wide_int mask = wi::mask (size, false, GET_MODE_PRECISION (mode)); - x = gen_rtx_AND (mode, x, immed_wide_int_const (mask, mode)); + if (!(GET_CODE (x) == LSHIFTRT + && CONST_INT_P (XEXP (x, 1)) + && size + INTVAL (XEXP (x, 1)) == GET_MODE_PRECISION (mode))) + { + wide_int mask = wi::mask (size, false, GET_MODE_PRECISION (mode)); + x = gen_rtx_AND (mode, x, immed_wide_int_const (mask, mode)); + } SUBST (**iter, x); changed = true; -- 2.30.2