From patchwork Mon Oct 2 19:35:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 820646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463351-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WQFqrqLI"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y5XTL2Zw6z9s0g for ; Tue, 3 Oct 2017 06:35:59 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=WLMdmRxnY61M dmPMAUjDK85s+AHU4WXRBaHc/LqtjkemD35VFd5AV7bdX0IND5K50FwvXTsBU5V1 +DSpA2unZe4mLjgrdMpGk7nr9cbvNJeGyUpn7O8VqIqtDP7frHr01/3PeYDK8oBo 6psjAYtv7Ors9EP+p/ohQG29kchxw2w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=/W6sYi1XKpJhb5toPA uEZHR8QHE=; b=WQFqrqLIPKub6OmJTJ7ViNZBtQUpGbew9ss2wwaT43TKfGnPZq LGcIkukjW1kFGgh1IVeDJ95KHo+tnFy8VnyM763ZKcZL89Y0T2AU8SXvw44Tkxw2 uhW1sRozYdI5gWKrHqqHjHjbrtoXQzirVaVzpHyeu/jhLMHZPWAffT5fA= Received: (qmail 77075 invoked by alias); 2 Oct 2017 19:35:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 77065 invoked by uid 89); 2 Oct 2017 19:35:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=million 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; Mon, 02 Oct 2017 19:35:50 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 6A643124024F; Mon, 2 Oct 2017 19:35:49 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] simplify-rtx: Remove non-simplifying simplification (PR77729) Date: Mon, 2 Oct 2017 19:35:46 +0000 Message-Id: <2ea52095880beff41ff1e53c7ebb6d7c6c35626c.1506971600.git.segher@kernel.crashing.org> X-IsSubscribed: yes If we have (X&C1)|C2 simplify_binary_operation_1 makes C1 as small as possible. This makes worse code in common cases like when the AND with C1 is from a zero-extension. This patch fixes it by removing this transformation (twice). I tested this on 31 targets, also some variations that do the transformation only for some conditions (like, do not do it if the resulting constant looks "worse", e.g. has more stretches of ones). 22 of those targets show no difference; 8 are best with this patch variant (never do the transformation); and 64-bit hppa is not best, but the difference is only four insns in a million. Bootstrapped and tested on powerpc64-linux {-m32,-m64}. Is this okay for trunk? And backports? Segher 2017-10-02 Segher Boessenkool PR rtl-optimization/77729 * simplify-rtx.c (simplify_binary_operation_1): Delete the (X&C1)|C2 to (X&(C1&~C2))|C2 transformations. --- gcc/simplify-rtx.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 1b960b9..3b6cf6f 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2673,14 +2673,6 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, /* If (C1|C2) == ~0 then (X&C1)|C2 becomes X|C2. */ if (((c1|c2) & mask) == mask) return simplify_gen_binary (IOR, mode, XEXP (op0, 0), op1); - - /* Minimize the number of bits set in C1, i.e. C1 := C1 & ~C2. */ - if (((c1 & ~c2) & mask) != (c1 & mask)) - { - tem = simplify_gen_binary (AND, mode, XEXP (op0, 0), - gen_int_mode (c1 & ~c2, mode)); - return simplify_gen_binary (IOR, mode, tem, op1); - } } /* Convert (A & B) | A to A. */ @@ -2736,23 +2728,6 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, return gen_rtx_ROTATE (int_mode, XEXP (opright, 0), XEXP (SUBREG_REG (opleft), 1)); - /* If we have (ior (and (X C1) C2)), simplify this by making - C1 as small as possible if C1 actually changes. */ - if (CONST_INT_P (op1) - && (HWI_COMPUTABLE_MODE_P (mode) - || INTVAL (op1) > 0) - && GET_CODE (op0) == AND - && CONST_INT_P (XEXP (op0, 1)) - && CONST_INT_P (op1) - && (UINTVAL (XEXP (op0, 1)) & UINTVAL (op1)) != 0) - { - rtx tmp = simplify_gen_binary (AND, mode, XEXP (op0, 0), - gen_int_mode (UINTVAL (XEXP (op0, 1)) - & ~UINTVAL (op1), - mode)); - return simplify_gen_binary (IOR, mode, tmp, op1); - } - /* If OP0 is (ashiftrt (plus ...) C), it might actually be a (sign_extend (plus ...)). Then check if OP1 is a CONST_INT and the PLUS does not affect any of the bits in OP1: then we can do