From patchwork Tue Nov 28 00:09:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 841913 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-468009-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="uh9lRca2"; 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 3ym3vY2ztpz9s3w for ; Tue, 28 Nov 2017 11:09:57 +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=dsolT9ZhhZHh MeUIHjVKniYyo44qyMfHQjk2Nqiy0EuHgrElI880eNG01wWQO0DTAFioLPsXHTzs cw3sk81VnfLd4pjB0xJ8HTJ33FBLzmzbnrBaKpc7WdpvcJUxrVlNJbn0uyGzIOhj XGfbCkMInGLNp/ZOq9/Gx4+KVJhipMA= 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=4TNQ41AxLWNA2lMPX2 eGoNf0zGU=; b=uh9lRca2wCH+lfYJw/mJ+lf029E6XIMcTRYgiOFaCRSa3QEfrj FmPto2cC4EkJH8IsviyAG/3Slhavd3Gev8qnABzLlTrqlvwUuqKj8PyPMgBsKDDx 0GoocYUKKfN3FuqYQwsqDV+rIhgWjkZKCxrCSLPs2LJr9Ky/AWO331BXA= Received: (qmail 113590 invoked by alias); 28 Nov 2017 00:09:47 -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 113578 invoked by uid 89); 28 Nov 2017 00:09:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=uns, leu, geu 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; Tue, 28 Nov 2017 00:09:44 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 1E53C12403D6; Tue, 28 Nov 2017 00:09:43 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH] rs6000: Improve scc isel Date: Tue, 28 Nov 2017 00:09:41 +0000 Message-Id: X-IsSubscribed: yes If we have a negative condition we can use a literal 0 in the isel, instead of having to load it into a register. If the condition is from a comparison with an immediate we can change e.g. LT to LE and adjust the immediate, saving a li instruction. Bootstrapped and tested on powerpc64-linux {-m32,-m64} (--with-cpu=power7 and forcing -misel on). Committing to trunk. Segher 2017-11-28 Segher Boessenkool * config/rs6000/rs6000.md (2_isel): Change LT/GT/LTU/GTU to LE/GE/LEU/GEU where possible. --- gcc/config/rs6000/rs6000.md | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 30db0c5..13ce53a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -12343,8 +12343,34 @@ (define_insn_and_split "2_isel" "&& 1" [(pc)] { - if ( == NE || == LE || == GE - || == LEU || == GEU) + rtx_code code = ; + if (CONST_INT_P (operands[2]) && code != EQ && code != NE) + { + HOST_WIDE_INT val = INTVAL (operands[2]); + if (code == LT && val != -0x8000) + { + code = LE; + val--; + } + if (code == GT && val != 0x7fff) + { + code = GE; + val++; + } + if (code == LTU && val != 0) + { + code = LEU; + val--; + } + if (code == GTU && val != 0xffff) + { + code = GEU; + val++; + } + operands[2] = GEN_INT (val); + } + + if (code == NE || code == LE || code == GE || code == LEU || code == GEU) operands[3] = const0_rtx; else { @@ -12363,14 +12389,16 @@ (define_insn_and_split "2_isel" rtx c1 = gen_rtx_COMPARE (mode, operands[1], operands[2]); emit_insn (gen_rtx_SET (operands[5], c1)); - rtx c2 = gen_rtx_fmt_ee (, mode, operands[5], const0_rtx); + rtx c2 = gen_rtx_fmt_ee (code, mode, operands[5], const0_rtx); rtx x = gen_rtx_IF_THEN_ELSE (mode, c2, operands[4], operands[3]); emit_move_insn (operands[0], x); DONE; } [(set (attr "cost") - (if_then_else (match_test " == NE || == LE || == GE + (if_then_else (match_test "(CONST_INT_P (operands[2]) && != EQ) + || == NE + || == LE || == GE || == LEU || == GEU") (const_string "9") (const_string "10")))])