From patchwork Wed Aug 23 20:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 716096 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1001875wrp; Wed, 23 Aug 2023 13:24:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDmAP1cXv8s+hu+RTl9ZLwQnZqU06ix/qlPXzZu44sCsABKtPcrN+kUlAg1RO1kV3A625Z X-Received: by 2002:a05:620a:190d:b0:76d:70d1:7ab1 with SMTP id bj13-20020a05620a190d00b0076d70d17ab1mr18510472qkb.27.1692822276581; Wed, 23 Aug 2023 13:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692822276; cv=none; d=google.com; s=arc-20160816; b=YOXr9jhAMwCvK8uTGxnPReoSi/kPlrToOR8Qjr2xEckW6Rdl22bi02AL80mOP6vWGL gO8Tc5UeUSZE/t39ZMP0pFcqvjpkjDGcgjm4+Pcwj+EvAKkOFKr3wgOUcs35kLv0O3Oc upufT7CSzd+n+PCaW0kpDQLXuf1f0IthgOWjngJq2ru6bBXYftiWnPidm08xC96sEjVN oVtQ+pyMYn7M3YknfCc/CqD0aTWlhqUcAfVM8WPLgfAMiWd8ryekku8+UlcUxi3rLIrd qvT9BgVTi0CZOZJSNm/ynDBjDqeSvxok6iFq19Njd6odsesALfJUVk7CHZJrH4nG8Cq8 +F+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=fwTSAJniEJxZbT4fbmyP3S6oSlLWMsUHRkmcSVO+gJc=; fh=iKWO5kImkBaf5P/04M2d2o+fJodoyCg8YLKe8/cbiwg=; b=ygN0xSArM5BGND3DgM4e3iXC1mhFaillHpT82UDf8mzzeEupy35l53y2QG/JtLcWaq 3y4V1nHfAY1XvmpVPKJxeTAkd24Ew9HIh+xldvKySwxWcBcPMAHKonADrd/9SB4115eS pXIqLa1VPe+82hNRMFB0olA0P82qX5RRdz0OHzlBoDWaRrzkPfAd6Z6BZB+ALgK72k3F D3sW3+V8cxMeLuIo4VVTOmCu9xlJ8GFwzPlTmhf4LRFhvTHU43y5xjZ/cRIFTG5Q0LaD nYKEfpkqDEK68XjSa+ChIi2cH8lFCw6YucLL3u8VaqOHl2XE0tqscpV0mDN7oal7eqsP x/vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CTgLdT3L; 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 e22-20020ac85996000000b00403cbe7e009si7820236qte.301.2023.08.23.13.24.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2023 13:24:36 -0700 (PDT) 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=CTgLdT3L; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYuOp-0000oS-Os; Wed, 23 Aug 2023 16:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYuOc-0008TR-KH for qemu-devel@nongnu.org; Wed, 23 Aug 2023 16:24:07 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYuOY-0005Yb-Na for qemu-devel@nongnu.org; Wed, 23 Aug 2023 16:24:06 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bf7a6509deso25220755ad.3 for ; Wed, 23 Aug 2023 13:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692822241; x=1693427041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fwTSAJniEJxZbT4fbmyP3S6oSlLWMsUHRkmcSVO+gJc=; b=CTgLdT3LVLYStCyduEeT75Q/bCHmjp80TJzhuG303Z6EaPIV3D7BixXpvp2T+pbpfh yPs7PdrpGiO/xHbwwNzHf+EgZ4GAGKkKq8lru+PnCuFpGJSVUN596lsWvGlYe1t8dzju RjbF3JGHwoU+GiOCjefy3xytgghZa+qvPYOHqLN7SrzjK/svcA0msOavIxW2KjA7V/2q 1YM9ExapQyWf3/0cOaxPypibgWbTbZ+UzsA3BAwduemUffWKG0YBFOu6HSWbap75Rf+Z Tph2OShEM8Y1R5MJxabIOLdcpxgnwojDk87kpF7FrUm0x9KNEC06QEzXTcgm1tslUlkS jL7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692822241; x=1693427041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fwTSAJniEJxZbT4fbmyP3S6oSlLWMsUHRkmcSVO+gJc=; b=NFXzL/nBxvqr6iQsW/nMbW03kHeSTOduVKHfz6oVuBDdUm/wqh4PVNbAsfmdFlFn4n 4gJ6seqfQm0fvfo+svefAedOmx60P1pu1mXZ0r/LKzMPPtY5T3wUiNyNxrzjQ06RlllP IBy+AxEccMjAOno09ZceschlFzrSaPQdNgZvUEi5G+p4xXCRLv5jyQhyiolaxxkZhZ8m YLJwcoIjQykl9VVIVTtwVzI8m/5bA89ieq8idgHxV7ozghvJyy2c2fCgy0kkFi3SDhTQ NWAzf+gW2HMH2Q4ldFYppA0PimZsffnfafIvp3QZioemHDM3we1YamOL3hbhdvqnErJi Q5yA== X-Gm-Message-State: AOJu0YytfnJnhMrMPCFu2pR2MWmIAzKFUEYlkO9TFQQrbb8/Gag5zC5Q WsiK3HjAvsRdDb/06Y/Lb+TF0LzglnUGPdXRGgQ= X-Received: by 2002:a17:902:b617:b0:1be:f76e:7664 with SMTP id b23-20020a170902b61700b001bef76e7664mr10151383pls.29.1692822240853; Wed, 23 Aug 2023 13:24:00 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:72f0:1ea7:85d2:141e]) by smtp.gmail.com with ESMTPSA id iz22-20020a170902ef9600b001b9da42cd7dsm11418641plb.279.2023.08.23.13.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 13:24:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 36/48] tcg/i386: Clear dest first in tcg_out_setcond if possible Date: Wed, 23 Aug 2023 13:23:14 -0700 Message-Id: <20230823202326.1353645-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823202326.1353645-1-richard.henderson@linaro.org> References: <20230823202326.1353645-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Using XOR first is both smaller and more efficient, though cannot be applied if it clobbers an input. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 4d7b745a52..3f3c114efd 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1532,6 +1532,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, int const_arg2) { bool inv = false; + bool cleared; switch (cond) { case TCG_COND_NE: @@ -1581,9 +1582,23 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, break; } + /* + * If dest does not overlap the inputs, clearing it first is preferred. + * The XOR breaks any false dependency for the low-byte write to dest, + * and is also one byte smaller than MOVZBL. + */ + cleared = false; + if (dest != arg1 && (const_arg2 || dest != arg2)) { + tgen_arithr(s, ARITH_XOR, dest, dest); + cleared = true; + } + tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); - tcg_out_ext8u(s, dest, dest); + + if (!cleared) { + tcg_out_ext8u(s, dest, dest); + } } #if TCG_TARGET_REG_BITS == 32