From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23153 invoked by alias); 15 Nov 2015 02:15:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23073 invoked by uid 89); 15 Nov 2015 02:15:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 15 Nov 2015 02:15:00 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id CDC511C0748; Sun, 15 Nov 2015 02:14:54 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] simplify-rtx: Simplify sign_extend of lshiftrt to zero_extend (PR68330) Date: Sun, 15 Nov 2015 02:15:00 -0000 Message-Id: <821bd594c0c0593a61208d2968ff2e52960ece00.1447553408.git.segher@kernel.crashing.org> X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg01857.txt.bz2 Since r230164, in PR68330 combine ends up with a sign_extend of an lshiftrt by some constant, and it does not know to morph that into a zero_extract (the extend will always extend with zeroes). I think it is best to let simplify-rtx always replace such a sign_extend by a zero_extend, after which everything works as expected. Bootstrapped and tested on powerpc64-linux. Is this okay for trunk? Segher 2015-11-15 Segher Boessenkool PR rtl-optimization/68330 * simplify-rtx.c (simplify_unary_operation_1): Simplify SIGN_EXTEND of LSHIFTRT by a non-zero constant integer. --- gcc/simplify-rtx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index c4fc42a..413d61b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1462,6 +1462,13 @@ simplify_unary_operation_1 (enum rtx_code code, machine_mode mode, rtx op) } } + /* (sign_extend:M (lshiftrt:N (const_int I))) is better as + (zero_extend:M (lshiftrt:N (const_int I))) if I is not 0. */ + if (GET_CODE (op) == LSHIFTRT + && CONST_INT_P (XEXP (op, 1)) + && XEXP (op, 1) != const0_rtx) + return simplify_gen_unary (ZERO_EXTEND, mode, op, GET_MODE (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 -- 1.9.3