From patchwork Thu Mar 3 20:59:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547819 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp980581imq; Thu, 3 Mar 2022 13:06:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoE7TArHuTFD15onN6OXF422tF2ExilX8RDeOOke4AhkNE6Sa1hNCNQ0ruwll1VGSKpCt2 X-Received: by 2002:a25:38d2:0:b0:628:dcae:447d with SMTP id f201-20020a2538d2000000b00628dcae447dmr1360890yba.84.1646341610290; Thu, 03 Mar 2022 13:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646341610; cv=none; d=google.com; s=arc-20160816; b=PrPxT4fP+NNbbVKYeisg0b9x4aqrw5PIde60BaTweV5NDy3E1+8mOdeMAYG3L19zf3 jltB0S5Gmiz//rgnheU5NVc12eQAt6hQF/prCHy2LvJL0zJHTzbTHma+4bnZ/To2CorZ DJwcgv2tNp3KA0E0+nDkaxhdN/mwC9sL6Er+Ej/EkMVi6n9YBseQpo+2UG4+kA0ZNlRr zZMoAHeUmgnVfDRdwd8PXRg3WLx4RxQ449it1HvAqzswKXesZptDhVuTxbHH1yQLDMxf BwIXKJOSBv8RZ7l1NvHIrjPqEbZcV+As3OkEYRRLS4ECHxmfLLnizzYcQdMFN9pZoByp Toiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=H//za3f5S9J3H+KCj3xVMYCo08x35IHoinSOucS409A=; b=MSQElgW0JZauvC9z7GvHTZIq7mgfqfPSGXbSkIrsZ4C2RQAGbqmq/EruSsgJBko1YQ iMFv4BqrsM5l9WY2GGFfREN73OovwdOb6cHBuK+06QubZ5I5YmwT41P6pkbgrcNrU23E lTSqkl3epoBbkoXGo/OkIqeA08hORE+jk+IK5yAz8IX1rXuGAroFIVN7ylrhNFryLC6P S4GgraGW8EfafDIVH9RZC4XrT8DB2N9wQy6h6KNAOS5wFLMpG7LXWFM32yKoS7tC0cz/ wa6kkJEzCIDsFOSVQ74E/WS3yFJZnXoaLvryBr7E50LEngs1yoKLmBJn1IgoR7KriDX+ oFWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UYf/DTNf"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j201-20020a8155d2000000b002dc10abf5d6si2614797ywb.210.2022.03.03.13.06.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Mar 2022 13:06:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UYf/DTNf"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPsev-0008Nd-Ki for patch@linaro.org; Thu, 03 Mar 2022 16:06:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsYC-00058M-4O for qemu-devel@nongnu.org; Thu, 03 Mar 2022 15:59:52 -0500 Received: from [2607:f8b0:4864:20::1030] (port=44715 helo=mail-pj1-x1030.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsYA-000420-91 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 15:59:51 -0500 Received: by mail-pj1-x1030.google.com with SMTP id gj15-20020a17090b108f00b001bef86c67c1so6034104pjb.3 for ; Thu, 03 Mar 2022 12:59:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H//za3f5S9J3H+KCj3xVMYCo08x35IHoinSOucS409A=; b=UYf/DTNfdFvd8+X0RzS8aUkB12v1a3/0Sig1ej3Ov6JqO6uLEyRhClN6XpKncMCO9F i2yd4+JchjXHvhuGV+pw3InMFV85IhFvqh1PeltxK8GuSXCNfs6x8hAkhU6do1MZ/mUu QlfWIufZHX7xJ4MAUT52Jup0FR7ZFsLVkmO/eew0//sIHYeqIGN2QrmWaGnm8lznT/+q 9nR4CDOzCV4Iboi4WGpFjnA+wFnZpQQrwVgAz+yP9qIuiB3JrTVLHbaudQOQkkvx3/D9 yiLPmi1gWIvYwz1C2O1TLUGJ9NuK7RJcdbZYiHnKRlvjuxbbNW/VMuXiLQ0ihzXx1r79 nSEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H//za3f5S9J3H+KCj3xVMYCo08x35IHoinSOucS409A=; b=Y/UM+J2cy5icKUQ3zukt3M0dQNLedOSYiYFu71A9A2vKZFQTSChC0FtS17pLNKIIlj 6OsUcNksO0AWiiJePfBggfoYZ4eNEjgSt0LE1bqDAf5ldCZyh2JTbReowxhnLYTzZsgU 0yvAq2jvrSp03wDEN2f7TZ5glRd0AZHzwoVOVP/1VHsXzmLGLfH2eRfybke3LxvV4cdN avhI1b9M3jWBSzazlb7JjflGCmV3r13AmxSPJzEmzLVTKV03/5D6/q4veOdvos+0NVkw ay2Awr7jj88KYCMEwLODX1Hs0xky41QqKPAserY0fMmPoYllN9tjiJuL3BP6xb4B5mqi ek1g== X-Gm-Message-State: AOAM5319TVCIOxvUkbW6FFYL/EIhhkIgGPAHKILrWyxREW3NYznvFsrE IQGMpcm9gK9hYIZg7AVkpSrsDNqkA0ZZMQ== X-Received: by 2002:a17:90b:17cb:b0:1bf:138d:e0f8 with SMTP id me11-20020a17090b17cb00b001bf138de0f8mr3590506pjb.157.1646341188936; Thu, 03 Mar 2022 12:59:48 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-119c-490c-a4ee-08e8.res6.spectrum.com. [2603:800c:1201:c600:119c:490c:a4ee:8e8]) by smtp.gmail.com with ESMTPSA id t8-20020a6549c8000000b00372eb3a7fb3sm2729934pgs.92.2022.03.03.12.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 12:59:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/30] tcg/optimize: only read val after const check Date: Thu, 3 Mar 2022 10:59:15 -1000 Message-Id: <20220303205944.469445-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303205944.469445-1-richard.henderson@linaro.org> References: <20220303205944.469445-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1030 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée valgrind pointed out that arg_info()->val can be undefined which will be the case if the arguments are not constant. The ordering of the checks will have ensured we never relied on an undefined value but for the sake of completeness re-order the code to be clear. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20220209112142.3367525-1-alex.bennee@linaro.org> Signed-off-by: Richard Henderson --- tcg/optimize.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e573000951..06213fd434 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -552,10 +552,10 @@ static bool do_constant_folding_cond_eq(TCGCond c) static int do_constant_folding_cond(TCGType type, TCGArg x, TCGArg y, TCGCond c) { - uint64_t xv = arg_info(x)->val; - uint64_t yv = arg_info(y)->val; - if (arg_is_const(x) && arg_is_const(y)) { + uint64_t xv = arg_info(x)->val; + uint64_t yv = arg_info(y)->val; + switch (type) { case TCG_TYPE_I32: return do_constant_folding_cond_32(xv, yv, c); @@ -567,7 +567,7 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, } } else if (args_are_copies(x, y)) { return do_constant_folding_cond_eq(c); - } else if (arg_is_const(y) && yv == 0) { + } else if (arg_is_const(y) && arg_info(y)->val == 0) { switch (c) { case TCG_COND_LTU: return 0;