From patchwork Thu Apr 13 16:55:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9679745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B0A360381 for ; Thu, 13 Apr 2017 16:56:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C7352869B for ; Thu, 13 Apr 2017 16:56:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31237286A7; Thu, 13 Apr 2017 16:56:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE4012869B for ; Thu, 13 Apr 2017 16:56:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754677AbdDMQ4V (ORCPT ); Thu, 13 Apr 2017 12:56:21 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:34984 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754073AbdDMQ4H (ORCPT ); Thu, 13 Apr 2017 12:56:07 -0400 Received: by mail-wr0-f193.google.com with SMTP id l44so9375944wrc.2 for ; Thu, 13 Apr 2017 09:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0pQM6Z8d1Bd9YwsbOwEdnx6jhtEZcrVAmiuj9jDVII4=; b=PNV9Acbvq6/9/H3vldi8vWPb9jvJ/Ox8adoxXR5DZm/QED/2CfE9GBo5iNIYQPMv/y 9jlmUewwYRBhBam50FFcX3fmjizUzpnx41qYBaniP3oP1q688cgznBzK5oQ/52i8o8fa CN4Cq9qtt187XMGtb3KqlwNyO7DXDQo9qSwuL5KEcHPeuYRYRsvxXLrPBnQsiNNemQmW 4q9Y/7j17VTMedYEVDfmMmAwIWYAuJIoDJMrWjDOIYcWS/BMZN1ktM+zTKbjkmRUHFMh uz0p+UgBuAZb7dTq3gEUva/fAsPvwdPYVUCvEQBCpdlyesR7siXPoqT9G0CGsaJWQ0t3 uGIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0pQM6Z8d1Bd9YwsbOwEdnx6jhtEZcrVAmiuj9jDVII4=; b=fXYofH4YxpXQsTXfH2vyakOn1t8RHtPpIGaus7/51X6L3ko1kjS+4zBggPbKQjwU1x fCUJEJxUaQhwz5FZDLb4EYvlBUs3Hyul6Bv3SovxDbLGPR2If5+r28on2VqF8zeUqb00 QnTImC52bbgFckoR7F3TboKGk/0U+GP9qZtZfrutr3dDvJh734LY0BYB9eVflR+MgAKc IpLT2fOL8XvQ0D257acxp9WJ0qExp2xzTgN0J4L06i/F2L5UbCq9cUoxr/GpaQSLJ+bs xIFTO3dofRjBcx6XBj1PBL/t084L8eilWRZ/aRyu//48FdyXyyClGK0/GVE5K59cIEyD pSIA== X-Gm-Message-State: AN3rC/4o7SfkEqJLwc6E3vA552CFq+x+U2ONxhq70C/ZEqg5dFyPcs5J aK5CSC5Uu6yAYfIWjrg= X-Received: by 10.223.160.87 with SMTP id l23mr4139017wrl.24.1492102565471; Thu, 13 Apr 2017 09:56:05 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:8b2:dc00:a909:829c:fd:bc60]) by smtp.gmail.com with ESMTPSA id q129sm13297803wmg.1.2017.04.13.09.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Apr 2017 09:56:04 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 8/8] avoid creating unneeded phi-sources Date: Thu, 13 Apr 2017 18:55:51 +0200 Message-Id: <20170413165551.2785-9-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170413165551.2785-1-luc.vanoostenryck@gmail.com> References: <20170413165551.2785-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In rewrite_load_instruction(), it's tested if the dominators are in fact all the same and if they are, as there is then no need for a phi-node, the newly created OP_PHISRCs are killed and the unique dominator is used in place of the phi-node. But in this case, it's a waste to have created the OP_PHISRCs as they are destroyed just after being created. Fix this by basically switching the order 'creating phi sources' and 'checking for uniqueness'. If the dominators are found to be all the same then use this unique dominator as the loaded value and no OP_PHISRC need to be created. Signed-off-by: Luc Van Oostenryck --- flow.c | 17 ++++++++--------- validation/loop-linearization.c | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/flow.c b/flow.c index d705abe2e..317074545 100644 --- a/flow.c +++ b/flow.c @@ -440,9 +440,7 @@ void rewrite_load_instruction(struct instruction *insn, struct instruction_list { struct pseudo_list *dominators; struct instruction *dom; - pseudo_t new, phi; - - dominators = add_load_dominators(insn, doms, ident); + pseudo_t new; /* * Check for somewhat common case of duplicate @@ -456,17 +454,18 @@ void rewrite_load_instruction(struct instruction *insn, struct instruction_list } END_FOR_EACH_PTR(dom); /* - * All the same pseudo - mark the phi-nodes unused - * and convert the load into a LNOP and replace the - * pseudo. + * All the same pseudo - convert the load into a pseudo. */ - FOR_EACH_PTR(dominators, phi) { - kill_instruction(phi->def); - } END_FOR_EACH_PTR(phi); convert_load_instruction(insn, new); return; complex_phi: + /* + * Not identical pseudos - create a phisrc for each + * dominators and convert the load into a phi-node. + */ + dominators = add_load_dominators(insn, doms, ident); + /* We leave symbol pseudos with a bogus usage list here */ if (insn->src->type != PSEUDO_SYM) kill_use(&insn->src); diff --git a/validation/loop-linearization.c b/validation/loop-linearization.c index d53366bde..ab731dc15 100644 --- a/validation/loop-linearization.c +++ b/validation/loop-linearization.c @@ -39,11 +39,11 @@ static int fdo(void) ffor: .L0: - phisrc.32 %phi5(i) <- $0 + phisrc.32 %phi3(i) <- $0 br .L4 .L4: - phi.32 %r1(i) <- %phi5(i), %phi6(i) + phi.32 %r1(i) <- %phi3(i), %phi4(i) setlt.32 %r2 <- %r1(i), $10 cbr %r2, .L1, .L3 @@ -58,7 +58,7 @@ ffor: .L2: add.32 %r7 <- %r1(i), $1 - phisrc.32 %phi6(i) <- %r7 + phisrc.32 %phi4(i) <- %r7 br .L4 .L3: @@ -73,11 +73,11 @@ ffor: fwhile: .L8: - phisrc.32 %phi11(i) <- $0 + phisrc.32 %phi7(i) <- $0 br .L12 .L12: - phi.32 %r8(i) <- %phi11(i), %phi12(i) + phi.32 %r8(i) <- %phi7(i), %phi8(i) setlt.32 %r9 <- %r8(i), $10 cbr %r9, .L9, .L11 @@ -87,51 +87,51 @@ fwhile: cbr %r11, .L14, .L13 .L13: - phisrc.32 %phi7(return) <- $0 + phisrc.32 %phi5(return) <- $0 br .L15 .L14: add.32 %r14 <- %r8(i), $1 - phisrc.32 %phi12(i) <- %r14 + phisrc.32 %phi8(i) <- %r14 br .L12 .L11: - phisrc.32 %phi8(return) <- $1 + phisrc.32 %phi6(return) <- $1 br .L15 .L15: - phi.32 %r12 <- %phi7(return), %phi8(return) + phi.32 %r12 <- %phi5(return), %phi6(return) ret.32 %r12 fdo: .L16: - phisrc.32 %phi16(i) <- $0 + phisrc.32 %phi11(i) <- $0 br .L17 .L17: - phi.32 %r15(i) <- %phi16(i), %phi17(i) + phi.32 %r15(i) <- %phi11(i), %phi12(i) push.32 %r15(i) call.32 %r16 <- p cbr %r16, .L18, .L20 .L20: - phisrc.32 %phi13(return) <- $0 + phisrc.32 %phi9(return) <- $0 br .L22 .L18: add.32 %r19 <- %r15(i), $1 setlt.32 %r20 <- %r15(i), $10 - phisrc.32 %phi17(i) <- %r19 + phisrc.32 %phi12(i) <- %r19 cbr %r20, .L17, .L19 .L19: - phisrc.32 %phi14(return) <- $1 + phisrc.32 %phi10(return) <- $1 br .L22 .L22: - phi.32 %r17 <- %phi13(return), %phi14(return) + phi.32 %r17 <- %phi9(return), %phi10(return) ret.32 %r17