From patchwork Wed Apr 12 19:33:42 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: 9678279 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 3203C601C3 for ; Wed, 12 Apr 2017 19:33:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2127F28635 for ; Wed, 12 Apr 2017 19:33:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15FA028644; Wed, 12 Apr 2017 19:33:59 +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 B310E28635 for ; Wed, 12 Apr 2017 19:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755140AbdDLTd6 (ORCPT ); Wed, 12 Apr 2017 15:33:58 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:32827 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755113AbdDLTd5 (ORCPT ); Wed, 12 Apr 2017 15:33:57 -0400 Received: by mail-wm0-f68.google.com with SMTP id o81so8546480wmb.0 for ; Wed, 12 Apr 2017 12:33:57 -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=63rI4q4Ul04AiB1pyqsZSSM2bdVj6aoyXzFF/MMFTWw=; b=bXkryyKN2TWSQC57/UCqneosxlUddTGPOedr0JWTtcnglkNVlinuEJooyXirL9fdkl Sx1rbErkfLcJy12Qtemq2RRVHqp4h+8RFGBwOxm/ye+KpXhwqSClAoE0+AOmp0252LDW OyL0h2GLYM0fNJ/DK6QEZokr7Ehm1oy5dbnKbkDOA+PlXBWCTXlMNiUZMbUI/NuuXlhp 6C1ivoY/llIZWWP7tTuOxQCYVM2+/D6SgOXs8S7INDRDONWP8bN2anHqz+YU1yvAPrBQ VQX1IBqrMR+DU/4fLEh5y14GNTOhYAEc4gUg1ikBabWBBsur1AZo85mXXfDBrKnVkzWC XPPg== 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=63rI4q4Ul04AiB1pyqsZSSM2bdVj6aoyXzFF/MMFTWw=; b=W1FHunl5A9mnLCk+WF+qvpknlph2C0r1WzXYbmE1K+hyK2nzV9RgCBCubETzIi51gd ev8PwSAwnU2VLWPPZv5K12Wf/S90gHgBMg0yn1TWXwxkYghLNfq6vWWWtelt7oYsr3JQ r/F/+P0OwwB93/3oMGKh04sTo9wDCzfzRiQfZIgWpSmHjeZu8HuEmiLkDTRN2cDLUeQN n382Fjk2b7O3FvdGw11W6NoZu9m/lU4JBcCNXWKSjiE9m/qb4ibdKPN4Xi24OU9Srgnv knQcsNOLrISFE1HXEzfae913xe9+AR6bjx+YVZKWbVrDJUFGvgDFCj/aH+NqExLPIoRG 9xUA== X-Gm-Message-State: AN3rC/5isqLY4UL2b/tilNRXns7yX70mWdlwGm+60BfAL/jvVBPKTR/D LaNVs1eILs3zOmvoc4M= X-Received: by 10.28.158.87 with SMTP id h84mr21397551wme.4.1492025635969; Wed, 12 Apr 2017 12:33:55 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:8b2:dc00:6c54:829e:388a:2472]) by smtp.gmail.com with ESMTPSA id h20sm7733401wmd.29.2017.04.12.12.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 12:33:55 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 4/6] generate plain OP_{AND,OR} instead of OP_{AND,OR}_BOOL Date: Wed, 12 Apr 2017 21:33:42 +0200 Message-Id: <20170412193344.95935-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170412193344.95935-1-luc.vanoostenryck@gmail.com> References: <20170412193344.95935-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 Now that OP_AND_BOOL and OP_OR_BOOL are always given boolean operands, they are just a special case of 1 bit OP_AND & OP_OR. To avoid to have to repeat CSE, simplification patterns, ... better to simply generate OP_AND & OP_OR instructions instead. Signed-off-by: Luc Van Oostenryck --- linearize.c | 2 +- validation/optim/bool-context-fp.c | 8 ++++---- validation/optim/bool-simplify.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/linearize.c b/linearize.c index e730ab56f..e6b77ec01 100644 --- a/linearize.c +++ b/linearize.c @@ -1379,7 +1379,7 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi static pseudo_t linearize_binop_bool(struct entrypoint *ep, struct expression *expr) { pseudo_t src1, src2, dst; - int op = (expr->op == SPECIAL_LOGICAL_OR) ? OP_OR_BOOL : OP_AND_BOOL; + int op = (expr->op == SPECIAL_LOGICAL_OR) ? OP_OR : OP_AND; src1 = linearize_expression_to_bool(ep, expr->left); src2 = linearize_expression_to_bool(ep, expr->right); diff --git a/validation/optim/bool-context-fp.c b/validation/optim/bool-context-fp.c index 2f15fe94d..3ce1574b9 100644 --- a/validation/optim/bool-context-fp.c +++ b/validation/optim/bool-context-fp.c @@ -53,7 +53,7 @@ bfior: setfval.32 %r19 <- 0.000000 fcmpune.1 %r20 <- %arg1, %r19 fcmpune.1 %r23 <- %arg2, %r19 - or-bool.1 %r24 <- %r23, %r20 + or.1 %r24 <- %r23, %r20 ret.1 %r24 @@ -63,7 +63,7 @@ ifior: setfval.32 %r29 <- 0.000000 fcmpune.1 %r30 <- %arg1, %r29 fcmpune.1 %r33 <- %arg2, %r29 - or-bool.1 %r34 <- %r33, %r30 + or.1 %r34 <- %r33, %r30 cast.32 %r35 <- (1) %r34 ret.32 %r35 @@ -74,7 +74,7 @@ bfand: setfval.32 %r38 <- 0.000000 fcmpune.1 %r39 <- %arg1, %r38 fcmpune.1 %r42 <- %arg2, %r38 - and-bool.1 %r43 <- %r42, %r39 + and.1 %r43 <- %r42, %r39 ret.1 %r43 @@ -84,7 +84,7 @@ ifand: setfval.32 %r48 <- 0.000000 fcmpune.1 %r49 <- %arg1, %r48 fcmpune.1 %r52 <- %arg2, %r48 - and-bool.1 %r53 <- %r52, %r49 + and.1 %r53 <- %r52, %r49 cast.32 %r54 <- (1) %r53 ret.32 %r54 diff --git a/validation/optim/bool-simplify.c b/validation/optim/bool-simplify.c index 2014d344c..b872764ca 100644 --- a/validation/optim/bool-simplify.c +++ b/validation/optim/bool-simplify.c @@ -18,6 +18,17 @@ int or_1(int a) return a || 1; } +// try again but with something true but != 1 +int and_2(int a) +{ + return a && 2; +} + +int or_2(int a) +{ + return a || 2; +} + /* * check-name: bool-simplify * check-command: test-linearize -Wno-decl $file @@ -49,5 +60,18 @@ or_1: ret.32 $1 +and_2: +.L8: + + setne.32 %r29 <- %arg1, $0 + ret.32 %r29 + + +or_2: +.L10: + + ret.32 $1 + + * check-output-end */