From patchwork Wed Oct 25 09:34:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117058 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp641926qgn; Wed, 25 Oct 2017 02:46:48 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Si9t5V//9HP9gwB3/XcTJOpQlekqK+nMRb/PqCkOboszO0jHgU2mB86dD2JYlWfi/Txcv/ X-Received: by 10.129.199.6 with SMTP id m6mr12605540ywi.136.1508924808377; Wed, 25 Oct 2017 02:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508924808; cv=none; d=google.com; s=arc-20160816; b=SkDu35N7OctTGnfzSnE2FutP4YR3rCavuZh+4uG5ME7WthU4h3OygSL3YDhmfTchDT 5K1l9RzH+rdD0T9KGimrJbyS7g4CjP1t8gaJYFMZP+Bn/Jhqk4s6/4hvEIkDaf37uF2r NTfPrTNj6jUGQ5aNGEnHKHN1L/mQ3ybxtpvvHcDANutoa36l6p0kKWtTN11d/j2baBmZ KFXssQXIm8eQ8z5QsbwEUinUUuO2KaaimLoMQCCIbId9a1ciDCv+GdNfIKNlWyDKnXoE d1jjuF9+xot1pWS6GoNigc4iscNSZqIKhlfvayXkT4es3cZeqjN25Z9eiHh7G1z24jzz 5dMg== 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=xAvi8WsStGoCyxvUCFFlIGyv7q4W2yjJKdqgcBRD4lc=; b=o+3OEDhCgUGIMsNYpoHeFp+swj4YjGIbsy7mRTD6P9xpeN/y6CtV9CG3rzeFnkOejV 8LiZ78OVFkCsr019RYz/TAFWF2Xtm1gkP7r1Dx7mwQ7bC6g5+ZWQO4qIccWdoPzxarc8 NlJJWF4xBlp9yxivPhVdGn4ofYJhNhvUz//SZxLEykKRwCDPJIEWqs878VZORS1sG6Kf UwfUG9GH3IBBIaS3ed7taGnZGb+YXalOe1yTapuxsKlGLbve+Fs/ftAE8l2ozznnmTv8 B1RMtVWEbhZLIkVlHqf0esjAT/Ua5x78bSOmNWBp80K//SI7JrJ/r+9b9KHSU2p35OOM 819g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=faNqSlKP; 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 c8si366573ybc.336.2017.10.25.02.46.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 02:46:48 -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=faNqSlKP; 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]:47354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7IGt-0000wU-T6 for patch@linaro.org; Wed, 25 Oct 2017 05:46:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7I6P-0008CK-Rr for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:35:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7I6L-00081i-T1 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:35:57 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:52546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7I6L-0007za-N1 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:35:53 -0400 Received: by mail-wr0-x241.google.com with SMTP id k62so23306625wrc.9 for ; Wed, 25 Oct 2017 02:35:53 -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=xAvi8WsStGoCyxvUCFFlIGyv7q4W2yjJKdqgcBRD4lc=; b=faNqSlKPob4YTqoT1C5kgV7n0k8jRqDNb4sYhZ1dmyvnFHgk+cxL9G4Y2Smd9Aianv OJ6B3tw304L6CcYzBl+Gn6hkw7YQ3X2Uepl2h8sUo/WmPPoO1sHHCuf2FueiLJL/R+uu bT0U/jFO9vbJyQp4VAzITBlvC5kqYMwu96SkQ= 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=xAvi8WsStGoCyxvUCFFlIGyv7q4W2yjJKdqgcBRD4lc=; b=R1v1RafYuHg7eSYVEmVD29zv4butgykmt/dz5crDUD5fiJE96FExfhIsIlSDgs+2da +Wwp0XZQOqDglZ7GyuRiZMQcwNA/BkkOYUEjUJb7Fb02E8Ui/cuQyBFTnOpi6O28wCEY WXfAqqqxoiROtTJkxZSUcNDdJBvpKtHVsuyJ/6sH35Nx+vMbi7n7NehIVblvfnAbhrCA 4xaevy+BH9ITdN5qPzdEiO3OX1ItDLim1Okm5EyvCwCZIS3JVihaq8gUeQul9HX2WKuh vsbJQsXUYSs+TxCKJjCeI0kCcW0PdvxdY63l8cueluiS0dM7yiYWh1nxQlD4OzI4XxJR HJZw== X-Gm-Message-State: AMCzsaUlcJsEkI5T5TSxvR4dMfgHqG7/sWcd7Yqd6tRGNcGihoHNerBt 7jy4GsWyrutAIQux+qLtd7GPuaN2Tr8= X-Received: by 10.223.186.66 with SMTP id t2mr1480171wrg.275.1508924152477; Wed, 25 Oct 2017 02:35:52 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.107]) by smtp.gmail.com with ESMTPSA id v23sm2751025wmh.8.2017.10.25.02.35.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 02:35:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 11:34:54 +0200 Message-Id: <20171025093535.10175-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025093535.10175-1-richard.henderson@linaro.org> References: <20171025093535.10175-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: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 10/51] tcg: Avoid loops against variable bounds 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, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Copy s->nb_globals or s->nb_temps to a local variable for the purposes of iteration. This should allow the compiler to use low-overhead looping constructs on some hosts. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Emilio G. Cota Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/tcg.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.c b/tcg/tcg.c index d08e34a9d8..840e65c0d4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1159,23 +1159,16 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, static void tcg_reg_alloc_start(TCGContext *s) { - int i; + int i, n; TCGTemp *ts; - for(i = 0; i < s->nb_globals; i++) { + + for (i = 0, n = s->nb_globals; i < n; i++) { ts = &s->temps[i]; - if (ts->fixed_reg) { - ts->val_type = TEMP_VAL_REG; - } else { - ts->val_type = TEMP_VAL_MEM; - } + ts->val_type = (ts->fixed_reg ? TEMP_VAL_REG : TEMP_VAL_MEM); } - for(i = s->nb_globals; i < s->nb_temps; i++) { + for (n = s->nb_temps; i < n; i++) { ts = &s->temps[i]; - if (ts->temp_local) { - ts->val_type = TEMP_VAL_MEM; - } else { - ts->val_type = TEMP_VAL_DEAD; - } + ts->val_type = (ts->temp_local ? TEMP_VAL_MEM : TEMP_VAL_DEAD); ts->mem_allocated = 0; ts->fixed_reg = 0; } @@ -2277,9 +2270,9 @@ static void temp_save(TCGContext *s, TCGTemp *ts, TCGRegSet allocated_regs) temporary registers needs to be allocated to store a constant. */ static void save_globals(TCGContext *s, TCGRegSet allocated_regs) { - int i; + int i, n; - for (i = 0; i < s->nb_globals; i++) { + for (i = 0, n = s->nb_globals; i < n; i++) { temp_save(s, &s->temps[i], allocated_regs); } } @@ -2289,9 +2282,9 @@ static void save_globals(TCGContext *s, TCGRegSet allocated_regs) temporary registers needs to be allocated to store a constant. */ static void sync_globals(TCGContext *s, TCGRegSet allocated_regs) { - int i; + int i, n; - for (i = 0; i < s->nb_globals; i++) { + for (i = 0, n = s->nb_globals; i < n; i++) { TCGTemp *ts = &s->temps[i]; tcg_debug_assert(ts->val_type != TEMP_VAL_REG || ts->fixed_reg