From patchwork Thu Mar 15 17:38:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 131833 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp1407000ljb; Thu, 15 Mar 2018 10:39:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELsphI8Wbr/WTW6bR8rEY+tZ83PmhaoVZuWjMR1bHlrmu9e6oE/IAcPc4JYWdmsJZRgziXzv X-Received: by 10.55.122.130 with SMTP id v124mr14208709qkc.140.1521135574158; Thu, 15 Mar 2018 10:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521135574; cv=none; d=google.com; s=arc-20160816; b=kClUgCgOMhQpJ73As+N4ejcYcnYJvctGeADitbP+7AlvX8hyqSVpstqTCWtFmHdljL 3NMqv3IooFAT7t+IuCk8nSdw2cHBUpLu8T8Q7PuT+TUzKrnBE3v13yPCkf7QLyZQtDP+ FQm4lMgU/DWcza+gKYHDywUyh9hBoaA2oevS4y/M+nZW+ZHk+ToFXylg2yezDeJqTAtH D9YQxO+6qEhdlPsVNJktkTQ8xUx57CoewaUlgoAnbEoXiNZR0G50dlg7XbvjewOoZFF9 I4V8+ek7lrnKBARonU3l2x5ZMmqjzwMZZh1/xIkX/GdyDHv2Ii2iqHAJRiG5YPTpPpyk 4i4Q== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=37ouaMvY5pTOVrhHJUAjWDoVOcGc1UxIbP09Exhmpzk=; b=fku4iRPo89wVui51GnyeU/p+wOxcqKJUuqCW24cmVZFkcgXwrWI6V70qxcqj+iSGBz GLgWoj30rj7kuw5vFoa2IDPj8a2Dvwo15AP5gv/tgRCzZEPEmwTBZjUJ3wIVQab10T5M uqGH5uMh9it1zexF/xAhztUGT0cDib9JaVct/4BctfNEh2QVkl/9AU8poITANaThbQ81 Zf7vjgS8oUeIKeHChlm7qaPpboQ+ZBSIshPvgIqcZtLkBbayZDuNhzHCwKgbEBv+md8N 78LskHpZk+a36lsBZrBjN5vuwPZ6seb+nmG1NhLO/auPmZhkeCWiH2Hhz5teu8tPzX1W dONQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A70ThDuA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u23si1378739qtu.306.2018.03.15.10.39.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 15 Mar 2018 10:39:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A70ThDuA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewWqj-0003RJ-J5 for patch@linaro.org; Thu, 15 Mar 2018 13:39:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewWqK-0003PO-3M for qemu-devel@nongnu.org; Thu, 15 Mar 2018 13:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ewWqI-00051L-UP for qemu-devel@nongnu.org; Thu, 15 Mar 2018 13:39:08 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:36070) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ewWqI-00050s-P2 for qemu-devel@nongnu.org; Thu, 15 Mar 2018 13:39:06 -0400 Received: by mail-pf0-x244.google.com with SMTP id 68so3100101pfx.3 for ; Thu, 15 Mar 2018 10:39:06 -0700 (PDT) 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=37ouaMvY5pTOVrhHJUAjWDoVOcGc1UxIbP09Exhmpzk=; b=A70ThDuAqujtfy8+e8fE9DjlmDbTbzaaGMGwidubucuZ7KV9PsKP8lRsNLOEVcweaa DPtbEEpNeDrUKhcE7zCJoq4YrFn9haQZNxzHZrz7/VofJlutTNp/iwgvCBXOiSVnM7M0 0eOcSRRK6hUDhCyzBFnuKERE3rZNRtfFKA8eI= 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:mime-version:content-transfer-encoding; bh=37ouaMvY5pTOVrhHJUAjWDoVOcGc1UxIbP09Exhmpzk=; b=WscRwjS0s1ZLONLKuSI6LHsZvn4xwuHewESiCfUQ2XQEYyxlMTIWSwEEMPoUzPNGRs UzSY7cVfGWgy7vi05rlmsK/MAukDg1fz7XUe+MHigAjtbj6dv4kjGBKwUizDhmdNgBka 5oqrj0sBFvDSmEVZ0/Glda4mF7yEr+oxL7+gC5WaU2bRubU0Gznv2E4/so9jF4C56U9z 6zPJGJBLKeCKcS6vCvRR7SU1mqfYSIjahn6K6xK7hZ0HTYtSOdyDlCezGZoNthKgWFVy 9UTL8m84QQEedGxvh8DhVJdf8dEitbIor/BKGptwhv7xniYPbQc12gIOKtAUVVddHX4w lawQ== X-Gm-Message-State: AElRT7GLuKwUvZHP5JrlhoFipb0cwLRns7aqvgAIzynzdwzVNVQixF0t QayY3OGhE95fRE1vxjUfnRB4HGR1JPg= X-Received: by 10.99.156.17 with SMTP id f17mr7327442pge.102.1521135545384; Thu, 15 Mar 2018 10:39:05 -0700 (PDT) Received: from cloudburst.twiddle.net ([182.239.119.25]) by smtp.gmail.com with ESMTPSA id f6sm9684571pgo.58.2018.03.15.10.39.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Mar 2018 10:39:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 16 Mar 2018 01:38:53 +0800 Message-Id: <20180315173855.22456-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180315173855.22456-1-richard.henderson@linaro.org> References: <20180315173855.22456-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PULL v2 1/3] tcg: Improve tcg_gen_muli_i32/i64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert multiplication by power of two to left shift. Reviewed-by: Emilio G. Cota Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) -- 2.14.3 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 3467787323..34b96d68f3 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -277,9 +277,15 @@ void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret, void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) { - TCGv_i32 t0 = tcg_const_i32(arg2); - tcg_gen_mul_i32(ret, arg1, t0); - tcg_temp_free_i32(t0); + if (arg2 == 0) { + tcg_gen_movi_i32(ret, 0); + } else if (is_power_of_2(arg2)) { + tcg_gen_shli_i32(ret, arg1, ctz32(arg2)); + } else { + TCGv_i32 t0 = tcg_const_i32(arg2); + tcg_gen_mul_i32(ret, arg1, t0); + tcg_temp_free_i32(t0); + } } void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) @@ -1430,9 +1436,15 @@ void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret, void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) { - TCGv_i64 t0 = tcg_const_i64(arg2); - tcg_gen_mul_i64(ret, arg1, t0); - tcg_temp_free_i64(t0); + if (arg2 == 0) { + tcg_gen_movi_i64(ret, 0); + } else if (is_power_of_2(arg2)) { + tcg_gen_shli_i64(ret, arg1, ctz64(arg2)); + } else { + TCGv_i64 t0 = tcg_const_i64(arg2); + tcg_gen_mul_i64(ret, arg1, t0); + tcg_temp_free_i64(t0); + } } void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)