From patchwork Sat Apr 22 08:22:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 86562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1576707vqo; Sat, 22 Apr 2023 01:23:19 -0700 (PDT) X-Google-Smtp-Source: AKy350a3FKW/mAnhlzAkYNDKyCS+o9WOgeDOZMTS4vWI26JQoxmBl0hKPQLOb4p2jG55Uy/f0mHk X-Received: by 2002:a17:906:5a68:b0:94e:ea07:4b87 with SMTP id my40-20020a1709065a6800b0094eea074b87mr4510969ejc.27.1682151798855; Sat, 22 Apr 2023 01:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682151798; cv=none; d=google.com; s=arc-20160816; b=nUApO/1UeCEh0+LdynWOTjUn7PhPdnCPuZtpO5j+uWknk7Cli3umiyZ3XfdbuXcDnb sT5nHkZd5xVFE2QESmFxvg+RpU5JBqwD9j2onhnJE7+0esU7kEXDuy6TE75drvO52TmK 58iGIv7WdexWQyeuG1uOdME2+qyXXKzjbjwGE9SMIt/CsjYBC3uYfA7S8cA5iaoPI5yS ttkxtzFYEFD88buiPVSaZtivbDB4b46migyqkew4QXw19yWqLM7j4sOV10EeVGUq/qsU sJL7FYxYUgH9mGJSfMUebiz8uggzJfNfTyYVLnQjWFM9al6e288wigXTbCkoWIszR6uG +MkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=bE4l/MvG4k/XUrf16XJx/PQVsgrP2lexQCiL4TSzvXE=; b=0M+pFdQhpaI8wa7Zi2k1dSwwFVrMndZdMLi6KcYG9Uv82kOvD5lAu4kfh8Cnr6kRSA JiR7fGbpjF9i0JuxbopqDcYrDbDh3zf2XlNZHns6aBNkA0xtL+mfk10bC74VMopzslxT gCYLj0OSM95Jq3HkjSY/J6l2jNRJbuNwgtObLT6Fwc3hUIowjyi9HjrPhstSIdxzLOfb cFc+gmYX4XRJ3Wa9QATXt+LfHJbxEPgXktk64xLNEvLdVEdPuZHuOswsZ6ujLSq13soz EfxZE0pXWCPPYyI8Nr+xq3MD8V0HBsjz2n3VzK0DyHCoiZuwh1OHm2qg5woh/vG9GLSB f33A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MaJITQCQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id lg18-20020a170906f89200b008cf961a7be1si2757606ejb.830.2023.04.22.01.23.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 01:23:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MaJITQCQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8215E3857716 for ; Sat, 22 Apr 2023 08:23:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8215E3857716 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682151797; bh=bE4l/MvG4k/XUrf16XJx/PQVsgrP2lexQCiL4TSzvXE=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=MaJITQCQ8mfe+8rUYt/rMZB/V5GprN/CGmTOE0yDOrIgxMnhQ9K3w3K0Zls0VSNPn ZxRLzng0Z423cO5e6fgcnIrJEh23qlu1ps3mEgPVDJlYRHqJu83t2hxfkQzaLr2wXW HHy+QCi6ZBslkwc3yx6O6FQXgiCuldBwfbA18k+s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A4CB53858C83 for ; Sat, 22 Apr 2023 08:22:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4CB53858C83 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-QI-I_KzwMnO0r1wDmLpLNw-1; Sat, 22 Apr 2023 04:22:28 -0400 X-MC-Unique: QI-I_KzwMnO0r1wDmLpLNw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 290B9800047; Sat, 22 Apr 2023 08:22:28 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCC3B2166B33; Sat, 22 Apr 2023 08:22:27 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 33M8MP0O2208070 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 22 Apr 2023 10:22:25 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33M8MO452208069; Sat, 22 Apr 2023 10:22:24 +0200 Date: Sat, 22 Apr 2023 10:22:23 +0200 To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] testsuite: Fix up pr109011-*.c tests for powerpc [PR109572] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763864004952735690?= X-GMAIL-MSGID: =?utf-8?q?1763864004952735690?= Hi! As reported, pr109011-{4,5}.c tests fail on powerpc. I thought they should have the same counts as the corresponding -{2,3}.c tests, the only difference is that -{2,3}.c are int while -{4,5}.c are long long. But there are 2 issues. One is that in the foo function the vectorization costs comparison triggered in, while in -{2,3}.c we use vectorization factor 4 and it was found beneficial, when using long long it was just vf 2 and the scalar cost of doing p[i] = __builtin_ctzll (q[i]) twice looked smaller than the vectorizated statements. I could disable the cost model, but instead chose to add some further arithmetics to those functions to make it beneficial even with vf 2. After that change, pr109011-4.c still failed; I was expecting 4 .CTZ calls there on power9, 3 vectorized and one in scalar code, but for some reason the scalar one didn't trigger. As I really want to count just the vectorized calls, I've added the vect prefix on the variables to ensure I'm only counting vectorized calls and decreased the 4 counts to 3. With this, the tests pass on x86_64-linux, i686-linux, powerpc64le-linux and powerpc64-linux (the last one -m32/-m64). Ok for trunk? 2023-04-22 Jakub Jelinek PR testsuite/109572 * gcc.dg/vect/pr109011-1.c: In scan-tree-dump-times regexps match also vect prefix to make sure we only count vectorized calls. * gcc.dg/vect/pr109011-2.c: Likewise. On powerpc* expect just count 3 rather than 4. * gcc.dg/vect/pr109011-3.c: In scan-tree-dump-times regexps match also vect prefix to make sure we only count vectorized calls. * gcc.dg/vect/pr109011-4.c: Likewise. On powerpc* expect just count 3 rather than 4. (foo): Add 2 further arithmetic ops to the loop to make it appear worthwhile for vectorization heuristics on powerpc. * gcc.dg/vect/pr109011-5.c: In scan-tree-dump-times regexps match also vect prefix to make sure we only count vectorized calls. (foo): Add 2 further arithmetic ops to the loop to make it appear worthwhile for vectorization heuristics on powerpc. Jakub --- gcc/testsuite/gcc.dg/vect/pr109011-1.c.jj 2023-04-20 16:30:21.684160677 +0200 +++ gcc/testsuite/gcc.dg/vect/pr109011-1.c 2023-04-22 10:03:28.403367294 +0200 @@ -14,8 +14,8 @@ foo (long long *p, long long *q) p[i] = __builtin_popcountll (q[i]); } -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */ -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */ void bar (long long *p, long long *q) @@ -25,5 +25,5 @@ bar (long long *p, long long *q) p[i] = __builtin_clzll (q[i]); } -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */ -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */ --- gcc/testsuite/gcc.dg/vect/pr109011-2.c.jj 2023-04-20 16:30:21.684160677 +0200 +++ gcc/testsuite/gcc.dg/vect/pr109011-2.c 2023-04-22 10:03:47.194092051 +0200 @@ -29,7 +29,7 @@ baz (int *p, int *q) p[i] = __builtin_ffs (q[i]); } -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */ -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 4 "optimized" { target powerpc_p9vector_ok } } } */ -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 2 "optimized" { target s390_vx } } } */ -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target s390_vx } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */ --- gcc/testsuite/gcc.dg/vect/pr109011-3.c.jj 2023-04-20 16:30:21.684160677 +0200 +++ gcc/testsuite/gcc.dg/vect/pr109011-3.c 2023-04-22 10:04:00.481897412 +0200 @@ -28,5 +28,5 @@ baz (int *p, int *q) p[i] = __builtin_ffs (q[i]); } -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */ -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target powerpc_p8vector_ok } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */ --- gcc/testsuite/gcc.dg/vect/pr109011-4.c.jj 2023-04-20 16:30:21.684160677 +0200 +++ gcc/testsuite/gcc.dg/vect/pr109011-4.c 2023-04-22 10:04:15.694674578 +0200 @@ -10,7 +10,7 @@ foo (long long *p, long long *q) { #pragma omp simd for (int i = 0; i < 2048; ++i) - p[i] = __builtin_ctzll (q[i]); + p[i] = 2 * q[i] + __builtin_ctzll (q[i]); } void @@ -29,7 +29,7 @@ baz (long long *p, long long *q) p[i] = __builtin_ffsll (q[i]); } -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */ -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 4 "optimized" { target powerpc_p9vector_ok } } } */ -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 2 "optimized" { target s390_vx } } } */ -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target s390_vx } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */ --- gcc/testsuite/gcc.dg/vect/pr109011-5.c.jj 2023-04-20 16:30:21.684160677 +0200 +++ gcc/testsuite/gcc.dg/vect/pr109011-5.c 2023-04-22 10:04:28.351489185 +0200 @@ -9,7 +9,7 @@ foo (long long *p, long long *q) { #pragma omp simd for (int i = 0; i < 2048; ++i) - p[i] = __builtin_ctzll (q[i]); + p[i] = 2 * q[i] + __builtin_ctzll (q[i]); } void @@ -28,5 +28,5 @@ baz (long long *p, long long *q) p[i] = __builtin_ffsll (q[i]); } -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */ -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target powerpc_p8vector_ok } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */