From patchwork Mon Oct 23 12:30:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 116737 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4590289qgn; Mon, 23 Oct 2017 05:30:55 -0700 (PDT) X-Received: by 10.98.0.206 with SMTP id 197mr13196962pfa.194.1508761855799; Mon, 23 Oct 2017 05:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508761855; cv=none; d=google.com; s=arc-20160816; b=kHDcBEKZSATQvevu3ogTi9jHncb6xrcrAhBz9ZBvxx35noSEtj+PSbte2hs4fYmbbA RY2H9JM0My2MjVkiX2Y+8sYqxHSRI9tgpLRdAxEb0nR3UNjh2MdBGTZSBHh0G7rfF4qd BgG/s5hy7UaHfIkKFgz9ZjjeBh4oBAX0YRh9yH8G2pCuQYbdlR1Vi75Ziz8aBuugtF0A X51ErQsU7rNZ77ZvRyLWueiGSpDiYkknBwcl2Zh9XkQYckJOh2YvL3ApBOGUeidy5ZfM oZltfdnlVk1bvmEQ9W6urBmNdi8ejTfx3FPOgEie30SJSRMVgjV7Mce2lZweAp1YuZ1p iCcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=Ii+NuDiNpUtjhngML9jVh+2ksLBG1AaEaRO0RzTwu4Y=; b=Wb93juLSYrQnXFciULnvwJSAgrTF8snFnEkl3zk+AoA6RxRBFF1KB+wsqohw4SmQ7G wftilXNxEXwtvqFkonUKrAAgXx4tZcg17GJJrYGVEbXib5LBhmbYF+ZZJYvnMrJNSa+v tMjqBFQK8pcqx7I42UPDrAdKNTpsfv0rDSMdLr+9qc/oDoXvdhMJbJLko1uq5jhsFLBF TyrxiNCvHug+S7XbE2Fttr8Kaa9WvTuidstCrOTbV5QzT04n2EBdBy6ZL5elsMvbTX7P IT5xRCHjM/c1JjPUojRcOYDDANRunzhrPFDvhG08OemBRa47vn19DLRwpRejonzeHOQZ Cy7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=S3kKpAEv; spf=pass (google.com: domain of gcc-patches-return-464753-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464753-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t9si4873605pge.75.2017.10.23.05.30.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 05:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464753-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=S3kKpAEv; spf=pass (google.com: domain of gcc-patches-return-464753-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464753-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=JBaqlOBXW/CgOhKJhrhBBUe9R0auBSPIeCrqLGPFkTLEJ9 EA2wpahyC9EZyzXczM/TuqxxpV8YyYlBv8NvDjS1VVXkO5GDaF9OCq/f9SN/g5oo O1QdTpmhBMgYs1Z6GG0jE0NXNqnmpZCnq0RQAlC3yGh71fpXTu/nnjK+7CDV4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=tQV97uUvTRZnk2L9U23fPi8pL5Q=; b=S3kKpAEv4QA1hYFkRwn0 thyJIGy6v/XiCfjPwV+dZa7aq91wh8+DOJn1IJe5ivp88luqo+O+vqTJoTtg6QyI qW+eIiJYcQ6kTMXvt9I97GWa7p1rDj3nd5bDJMMdAiaoMrPIbttu8exLOg492sTI J0/opqgek3jCI6jEpN5GCYY= Received: (qmail 19988 invoked by alias); 23 Oct 2017 12:30:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14657 invoked by uid 89); 23 Oct 2017 12:30:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:builtin-bswap-7.c, 2947, fnoinline, fno-inline X-HELO: mail-vk0-f49.google.com Received: from mail-vk0-f49.google.com (HELO mail-vk0-f49.google.com) (209.85.213.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 12:30:27 +0000 Received: by mail-vk0-f49.google.com with SMTP id t203so11006588vke.0 for ; Mon, 23 Oct 2017 05:30:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=kFkwh4G4nDaoZnMDPfy4/VCr6MrLZGpQ1C7CN5TcJkU=; b=DZuaIvUxMCdTeAVkI18FuuSCX43aXkEx1W34h9HP05QWqr+6rptzITMT0R4hIZHXO7 rc89/JHLxTobx/nrUjAV9FyUVy9aFAeiQIMAGfF5BMCVBpnqmI9iwlVZbUHUqwAVdpn2 bJPyePX7PE3cpBYsD5+6FsziN5z1VlkSBB1ot1tDCKiHGjyFlsQP5LJMstcCeFqgopP+ cEo8VqOxqTFHFWkNIIpgqeO2QKdYX5pJQuOXBGIaWiE/0Ie+of8OH+n95tjsaZ3UHNHz 4Zu7GfkPG77orJA90zeKdKbFNvUgmAZx6CJRBFDSTZhwWtDVpAdH0t8c0LbPYvNWIo70 vhKw== X-Gm-Message-State: AMCzsaXKAEpvA9bcAPGaH0ZvVbUSDJwupIs6m1bZykmFWbaQ6IfguGiV f+CfRSvo6ngiwBARDi8Yb02OTJNEh2b0k3eA7Caub+6t0KE= X-Google-Smtp-Source: ABhQp+StBMJGV3i99qe4oKQbJNgMpxfXAzbcWRYU5GPzot2eMeWS4ocPfbLO3NkZnhiH/BZgk1lV1Sg3OEsdwBnq770= X-Received: by 10.31.172.137 with SMTP id v131mr10118265vke.75.1508761825108; Mon, 23 Oct 2017 05:30:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.94.66 with HTTP; Mon, 23 Oct 2017 05:30:24 -0700 (PDT) From: Christophe Lyon Date: Mon, 23 Oct 2017 14:30:24 +0200 Message-ID: Subject: [Patch][ARM] Add -mbranch-cost option, and update a few tests To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes Hi, After Jakub's suggestion in PR82120 and PR81184, the attached patch adds the -mbranch-cost option to the ARM target. My understanding is that it's intended to be used internally for testing and does not require user-facing documentation. I have updated a few tests, validation on aarch64 & arm targets shows no regression, and a few improvements when targeting cortex-a5 or cortex-m3: gcc.dg/tree-ssa/reassoc-3[3456].c now pass. That being said, I'm not sure about the other targets for which I changed the condition, and I am also concerned by the fact that it has no impact on gcc.dg/pr21643.c and gcc.dg/tree-ssa/phi-opt-11.c (PR81184). Should I restrict my patch to the only tests where it has an impact (gcc.dg/tree-ssa/reassoc-3[3456].c) ? Thanks, Christophe gcc/ChangeLog: 2017-10-23 Christophe Lyon * config/arm/arm.opt (-mbranch-cost): New option. * config/arm/arm.h (BRANCH_COST): Take arm_branch_cost into account. gcc/testsuite/ChangeLog: 2017-10-23 Christophe Lyon * lib/target-supports.exp (check_effective_target_branch_cost): New function. * gcc.dg/builtin-bswap-7.c: Use branch_cost effective target. * gcc.dg/pr21643.c: Likewise. * gcc.dg/pr46309.c: Likewise. * gcc.dg/tree-ssa/phi-opt-11.c: Likewise. * gcc.dg/tree-ssa/phi-opt-2.c: Likewise. * gcc.dg/tree-ssa/reassoc-32.c: Likewise. * gcc.dg/tree-ssa/reassoc-33.c: Likewise. * gcc.dg/tree-ssa/reassoc-34.c: Likewise. * gcc.dg/tree-ssa/reassoc-35.c: Likewise. * gcc.dg/tree-ssa/reassoc-36.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-13.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c: Likewise. * gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c: Likewise. commit 0b21f80bf10d0273e6db4655654df9e125c0dae6 Author: Christophe Lyon Date: Fri Sep 8 12:27:42 2017 +0000 Add -mbranch-cost=N option for ARM. Change-Id: I4d570646c405f7b186d0d1be80ce1661ef022aea diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 2d71e8f..854c753 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -1946,8 +1946,9 @@ enum arm_auto_incmodes /* Try to generate sequences that don't involve branches, we can then use conditional instructions. */ -#define BRANCH_COST(speed_p, predictable_p) \ - (current_tune->branch_cost (speed_p, predictable_p)) +#define BRANCH_COST(speed_p, predictable_p) \ + ((arm_branch_cost != -1) ? arm_branch_cost : \ + (current_tune->branch_cost (speed_p, predictable_p))) /* False if short circuit operation is preferred. */ #define LOGICAL_OP_NON_SHORT_CIRCUIT \ diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index 6060516..a3719cb 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -294,3 +294,7 @@ When linking for big-endian targets, generate a BE8 format image. mbe32 Target Report RejectNegative Negative(mbe8) InverseMask(BE8) When linking for big-endian targets, generate a legacy BE32 format image. + +mbranch-cost= +Target RejectNegative Joined UInteger Var(arm_branch_cost) Init(-1) +Cost to assume for a branch insn. diff --git a/gcc/testsuite/gcc.dg/builtin-bswap-7.c b/gcc/testsuite/gcc.dg/builtin-bswap-7.c index 3e1718d..fe85441 100644 --- a/gcc/testsuite/gcc.dg/builtin-bswap-7.c +++ b/gcc/testsuite/gcc.dg/builtin-bswap-7.c @@ -5,7 +5,7 @@ /* The branch cost setting prevents the return value from being calculated with arithmetic instead of doing a compare. */ -/* { dg-additional-options "-mbranch-cost=0" { target s390x-*-* } } */ +/* { dg-additional-options "-mbranch-cost=0" { target branch_cost } } */ #include diff --git a/gcc/testsuite/gcc.dg/pr21643.c b/gcc/testsuite/gcc.dg/pr21643.c index bd76aa8..d981fbc 100644 --- a/gcc/testsuite/gcc.dg/pr21643.c +++ b/gcc/testsuite/gcc.dg/pr21643.c @@ -1,6 +1,7 @@ /* PR tree-optimization/21643 */ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-reassoc1-details" } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int f1 (unsigned char c) diff --git a/gcc/testsuite/gcc.dg/pr46309.c b/gcc/testsuite/gcc.dg/pr46309.c index 68229cf..c964529 100644 --- a/gcc/testsuite/gcc.dg/pr46309.c +++ b/gcc/testsuite/gcc.dg/pr46309.c @@ -4,7 +4,7 @@ /* The transformation depends on BRANCH_COST being greater than 1 (see the notes in the PR), so try to force that. */ /* { dg-additional-options "-mtune=octeon2" { target mips*-*-* } } */ -/* { dg-additional-options "-mbranch-cost=2" { target avr*-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int f1 (int a) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c index cda3abf..20728fc 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int f(int a, int b, int c) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c index 1408122..e0b2618 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=1" { target { i?86-*-* x86_64-*-* mips*-*-* s390*-*-* avr*-*-* } } } */ +/* { dg-additional-options "-mbranch-cost=1" { target branch_cost } } */ _Bool f1(_Bool a, _Bool b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-32.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-32.c index 3ac1fb6..b6ca8e2 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-32.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-32.c @@ -1,7 +1,7 @@ /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-*"} } } */ /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int test (int a, int b, int c) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c index 6811a42..5572df4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c @@ -1,7 +1,7 @@ /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */ /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int test (int a, int b, int c) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c index 523654d..9b45f1c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c @@ -1,7 +1,7 @@ /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */ /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int test (int a, int b, int c) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c index 216604e..9ee3abc 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c @@ -1,7 +1,7 @@ /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */ /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int test (unsigned int a, int b, int c) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c index dbbf8a1..ac3a042 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c @@ -1,7 +1,7 @@ /* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */ /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int test (int a, int b, int c) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c index 7f4f011..5f3147a 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized-details-blocks" } */ -/* { dg-additional-options "-mbranch-cost=2" { target { i?86-*-* x86_64-*-* s390*-*-* avr*-*-* } } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ _Bool f1(_Bool a, _Bool b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c index acfcb7d..1714fcf 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-1.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */ /* { dg-options "-O2 -g -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int t (int a, int b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c index 0435d55..f35ec5e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-2.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */ /* { dg-options "-O2 -g -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int t (int a, int b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c index 4f2b570..d84bdd5 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-3.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */ /* { dg-options "-O2 -g -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int t (int a, int b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c index 9c64b5e..be0ee26 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-4.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */ /* { dg-options "-O2 -g -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int t (int a, int b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c index 8cd4a60..09c22ab 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-5.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */ /* { dg-options "-O2 -g -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int t (int a, int b, int c) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c index c161b16..a0dc82d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-ccmp-6.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { ! { { logical_op_short_circuit && { ! avr-*-* } } || { m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* arc*-*-* mips*-*-* } } } } } */ /* { dg-options "-O2 -g -fdump-tree-optimized" } */ -/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */ int t (int a, int b, int c) { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 3ddc92e..8ffd1c4 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -8184,6 +8184,24 @@ proc check_effective_target_logical_op_short_circuit {} { return 0 } +# Return 1 if the target supports -mbranch-cost=N option. + +proc check_effective_target_branch_cost {} { + if { [ istarget arm*-*-*] + || [istarget avr*-*-*] + || [istarget epiphany*-*-*] + || [istarget frv*-*-*] + || [istarget i?86-*-linux*] || [istarget x86_64-*-linux*] + || [istarget mips*-*-*] + || [istarget s390*-*-*] + || [istarget riscv*-*-*] + || [istarget sh*-*-*] + || [istarget spu*-*-*] } { + return 1 + } + return 0 +} + # Record that dg-final test TEST requires convential compilation. proc force_conventional_output_for { test } {