{"id":2228934,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2228934/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260427140254.F21AB4B9DB77@sourceware.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260427140254.F21AB4B9DB77@sourceware.org>","date":"2026-04-27T14:02:22","name":"[RFC] flip --param ix86-vect-compare-costs default","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cbcfd51de0706bdfa4529d2ea6a2aa001c4a7ea9","submitter":{"id":4338,"url":"http://patchwork.ozlabs.org/api/1.1/people/4338/?format=json","name":"Richard Biener","email":"rguenther@suse.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260427140254.F21AB4B9DB77@sourceware.org/mbox/","series":[{"id":501656,"url":"http://patchwork.ozlabs.org/api/1.1/series/501656/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501656","date":"2026-04-27T14:02:22","name":"[RFC] flip --param ix86-vect-compare-costs default","version":1,"mbox":"http://patchwork.ozlabs.org/series/501656/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2228934/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228934/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=AW6NrJgl;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=qoLJhkHP;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=IWK4eO8s;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=j2uvp0po;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=AW6NrJgl;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=qoLJhkHP;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=IWK4eO8s;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=j2uvp0po","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=suse.de","sourceware.org; spf=pass smtp.mailfrom=suse.de","server2.sourceware.org;\n arc=none smtp.remote-ip=195.135.223.131","smtp-out2.suse.de;\n\tnone"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g44yp1PpZz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 00:02:56 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id F21AB4B9DB77\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 14:02:54 +0000 (GMT)","from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131])\n by sourceware.org (Postfix) with ESMTPS id E2B124B9DB74\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 14:02:24 +0000 (GMT)","from murzim.nue2.suse.org (unknown [10.168.4.243])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out2.suse.de (Postfix) with ESMTPS id C9EF45BD27;\n Mon, 27 Apr 2026 14:02:22 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org F21AB4B9DB77","OpenDKIM Filter v2.11.0 sourceware.org E2B124B9DB74"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org E2B124B9DB74","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org E2B124B9DB74","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777298545; cv=none;\n b=puempM4F5GYMgQ9+MGkKz7EcW4yrfHFLV9/PRb5HlX/oHO8+CxRrG7Cv8b0WE5MomFqUX1zmnKYRMT8uNZq/jZ7sHqddaynMqwB6ZZsB09Jhvz1y4d7eA2U/EaZZamt9H82AI4ry5a4nA/HE1uG+bO6n6L7Yp8Q5on05TzhZR58=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777298545; c=relaxed/simple;\n bh=W6mciIY/LKGvkYAk3yuHHhvp8flewAFwflcGC8GR1U4=;\n h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date:\n From:To:Subject:MIME-Version;\n b=lC7tJ3HXrhEicxqNV4/OZ5GDrUETwGlay/vAP5d5vS8R/CK4AK4FL8yy8elujVsJ5cmykMLhG6soiZoPZ/yoxAV64689Iy7yB/pQg45/gHiHkO3sq+oqNRGnFQ/6NSvyQTe3b1n6WPoXlG8KFc9zlblrkU0rppRBLW7lUghfHNQ=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1777298543;\n h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=yrbTjWCNrFZUbgUWo/jcsjlOMddtcRIjjqpAVyQP1I0=;\n b=AW6NrJgl/GFWvqGrd85fDy5sViUL0iecXwPoet/3Akc0DthOfGLGJ6FpPyTVoEo4c28qjc\n 04JFU5bAvS0idlG6QaRdV+17uA+sNj82zPw0DnQDOSl6kFJ559AIsiWuI+38Uhd2w/Ce9a\n aMtvOkIIGbYbRi+V01sxX2OmmVMrPR0=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1777298543;\n h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=yrbTjWCNrFZUbgUWo/jcsjlOMddtcRIjjqpAVyQP1I0=;\n b=qoLJhkHP2upnmr0iqQNhES035mIy234PkMLy5f3bGfT1/nnPtWXba8hq6rIC3TociZkw3R\n /8lSFvKu7rWvuhAA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1777298542;\n h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=yrbTjWCNrFZUbgUWo/jcsjlOMddtcRIjjqpAVyQP1I0=;\n b=IWK4eO8s94xw3O7vWGuuW1z0yHVR7oN0KETk0O90j9JRhA1xg1bk2ajInJhZI+gnGK9sth\n hbiYDsepYys6rUvOz12wa9mLoG5Hc4LWRr/f69/QZNRVGsq7e0pbWWkyuWJGXxwqpp8jQH\n P0nivwED/ydRC/CD48QBZIAfn3DavvA=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1777298542;\n h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=yrbTjWCNrFZUbgUWo/jcsjlOMddtcRIjjqpAVyQP1I0=;\n b=j2uvp0poT6uW/4BHKA3nDilc0NWGUaDiy7MoYSGtrMj4KM/rEhNIM5qB5Wp0C3bpMpx+8W\n 3T6rSihjf/BWdXBA=="],"Date":"Mon, 27 Apr 2026 16:02:22 +0200 (CEST)","From":"Richard Biener <rguenther@suse.de>","To":"gcc-patches@gcc.gnu.org","cc":"tamar.christina@arm.com, rdapp.gcc@gmail.com, hongtao.liu@intel.com","Subject":"[PATCH][RFC] flip --param ix86-vect-compare-costs default","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","X-Spamd-Result":"default: False [-0.30 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n MISSING_MID(2.50)[]; SUSPICIOUS_RECIPS(1.50)[];\n NEURAL_HAM_LONG(-1.00)[-1.000];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n FUZZY_RATELIMITED(0.00)[rspamd.com]; MISSING_XM_UA(0.00)[];\n TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+];\n RCVD_COUNT_ZERO(0.00)[0]; FREEMAIL_ENVRCPT(0.00)[gmail.com];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n FROM_HAS_DN(0.00)[];\n FREEMAIL_CC(0.00)[arm.com,gmail.com,intel.com];\n RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[];\n TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[];\n DBL_BLOCKED_OPENRESOLVER(0.00)[murzim.nue2.suse.org:helo,gcc.target:url]","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org","Message-Id":"<20260427140254.F21AB4B9DB77@sourceware.org>"},"content":"The following flips the default of ix86-vect-compare-costs as discussed\nduring stage3/4.  It adds the testcase from PR120398 and ensures the\nexisting one works without specifying the --param.\n\nSome testcases need simple dump scan adjustments but some show actual\ncode generation changes.\n\ngcc.target/i386/vect-partial-vectors-2.c shows that we lose the special\nhandling of a loop that can be handled by solely the masked epilog,\nwe have a using_partial_vectors_p loop vs. a not using_partial_vectors_p\nand do not account for the epilog cost of the latter in the default\nvector_costs::better_main_loop_than_p\n\ngcc.target/i386/shift-gf2p8affine-[137].c and\ngcc.target/i386/vect-epilogues-{2,3}.c and gcc.target/i386/vect-pr113078.c\nshow that epilog loop costing now factors in a guesstimate of the remaining\nscalar epilog cost and that can easily skew us to using a smaller single\nvector epilog.  That also does not consider the possibility of vectorizing\nthat epilog.\n\ngcc.target/i386/vect-epilogues-10.c shows that we compute the\nmasked epilog to be more expensive than the not masked one.  That's\nprobably correct as we're facing an in-order reduction.  I have\nadded -fno-vect-cost-model given this is a testcase for a missing\nfeature.\n\ngcc.target/i386/vect-strided-[1234].c computes it's better to use\nV2SImode vectorization than V4SImode as we can elide shuffling.\n\nI most of the above are symptoms of the vectorizer trying to cost\nmain loop and epilog loop(s) on their own, rather than costing\nthe whole set of main + epilog loop(s) and compare sets against\neach other.  We can probably do something sensible in a target\nspecific better_{epilog,main}_loop_than_p by guessing about\n(further) epilog loops.  Still separating in particular the\nguessed cost of the scalar epilog that vect_estimate_min_profitable_iters\nadds to epilog cost might make sense as at least for reductions\nthere's also \"real\" vector epilog costs.\n\nAny thoughts?\n\nThanks,\nRichard.\n\n\tPR tree-optimization/120398\n\tPR tree-optimization/123603\n\t* config/i386/i386.opt (ix86-vect-compare-costs): Default to 1.\n\n\t* gcc.dg/vect/costmodel/x86_64/costmodel-pr120398.c: New testcase.\n\t* gcc.dg/vect/costmodel/x86_64/costmodel-pr123603.c: Adjust.\n\t* gcc.target/i386/vect-alignment-peeling-1.c: Likewise.\n\t* gcc.target/i386/vect-alignment-peeling-2.c: Likewise.\n\t* gcc.target/i386/vect-epilogues-10.c: Add -fno-vect-cost-model.\n---\n gcc/config/i386/i386.opt                        |  2 +-\n .../vect/costmodel/x86_64/costmodel-pr120398.c  | 17 +++++++++++++++++\n .../vect/costmodel/x86_64/costmodel-pr123603.c  |  1 -\n .../gcc.target/i386/vect-alignment-peeling-1.c  |  2 +-\n .../gcc.target/i386/vect-alignment-peeling-2.c  |  2 +-\n .../gcc.target/i386/vect-epilogues-10.c         |  2 +-\n 6 files changed, 21 insertions(+), 5 deletions(-)\n create mode 100644 gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr120398.c","diff":"diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt\nindex 3b530944a36..ff08188c761 100644\n--- a/gcc/config/i386/i386.opt\n+++ b/gcc/config/i386/i386.opt\n@@ -1258,7 +1258,7 @@ Target Joined UInteger Var(ix86_vect_unroll_limit) Init(4) Param\n Limit how much the autovectorizer may unroll a loop.\n \n -param=ix86-vect-compare-costs=\n-Target Joined UInteger Var(ix86_vect_compare_costs) Init(0) IntegerRange(0, 1) Param Optimization\n+Target Joined UInteger Var(ix86_vect_compare_costs) Init(1) IntegerRange(0, 1) Param Optimization\n Whether x86 vectorizer cost modeling compares costs of different vector sizes.\n \n mlam=\ndiff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr120398.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr120398.c\nnew file mode 100644\nindex 00000000000..e348c8eb550\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr120398.c\n@@ -0,0 +1,17 @@\n+/* { dg-do compile } */\n+\n+static float muladd(float x, float y, float z)\n+{\n+    return x * y + z;\n+}\n+float g(float x[], long n)\n+{\n+    float r0 = 0, r1 = 0;\n+    for (; n; x += 2, n--) {\n+        r0 = muladd(x[0], x[0], r0);\n+        r1 = muladd(x[1], x[1], r1);\n+    }\n+    return r0 + r1;\n+}\n+\n+/* { dg-final { scan-tree-dump \"optimized: loop vectorized using 8 byte vectors\" \"vect\" } } */\ndiff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr123603.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr123603.c\nindex c074176a7e4..6509aaac713 100644\n--- a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr123603.c\n+++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr123603.c\n@@ -1,5 +1,4 @@\n /* { dg-do compile } */\n-/* { dg-additional-options \"--param ix86-vect-compare-costs=1\" } */\n \n void foo (int *block)\n {\ndiff --git a/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-1.c b/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-1.c\nindex cec959f3e07..d24b143a47d 100644\n--- a/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-1.c\n+++ b/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-1.c\n@@ -90,6 +90,6 @@ int main()\n       __builtin_abort ();\n }\n \n-/* { dg-final { scan-tree-dump-times \"Alignment of access forced using peeling\" 4 \"vect\" } } */ \n+/* { dg-final { scan-tree-dump-times \"Alignment of access forced using peeling\" 7 \"vect\" } } */ \n /* Verify all vector accesses are emitted as aligned.  */\n /* { dg-final { scan-assembler-not \"movup\" } } */\ndiff --git a/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-2.c b/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-2.c\nindex 0317c77a389..67a5ce9c181 100644\n--- a/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-2.c\n+++ b/gcc/testsuite/gcc.target/i386/vect-alignment-peeling-2.c\n@@ -90,6 +90,6 @@ int main()\n       __builtin_abort ();\n }\n \n-/* { dg-final { scan-tree-dump-times \"Alignment of access forced using peeling\" 4 \"vect\" } } */ \n+/* { dg-final { scan-tree-dump-times \"Alignment of access forced using peeling\" 7 \"vect\" } } */ \n /* Verify all vector accesses are emitted as aligned.  */\n /* { dg-final { scan-assembler-not \"movup\" } } */\ndiff --git a/gcc/testsuite/gcc.target/i386/vect-epilogues-10.c b/gcc/testsuite/gcc.target/i386/vect-epilogues-10.c\nindex a187955e6f1..2f660921e42 100644\n--- a/gcc/testsuite/gcc.target/i386/vect-epilogues-10.c\n+++ b/gcc/testsuite/gcc.target/i386/vect-epilogues-10.c\n@@ -1,5 +1,5 @@\n /* { dg-do compile } */\n-/* { dg-options \"-O3 -mavx512f -mprefer-vector-width=512 --param vect-partial-vector-usage=1 -fdump-tree-vect-optimized\" } */\n+/* { dg-options \"-O3 -mavx512f -mprefer-vector-width=512 --param vect-partial-vector-usage=1 -fdump-tree-vect-optimized -fno-vect-cost-model\" } */\n \n double foo (double *a, long long *mask, int n)\n {\n","prefixes":["RFC"]}