From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 36A1D385EC49; Wed, 14 Feb 2024 15:37:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36A1D385EC49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707925029; bh=DuSP35Fs44UQQx9pc/+OBgqg/3qd7zM5FNv3Pv/5svA=; h=From:To:Subject:Date:From; b=KGz/p1SR4pf6OEOkk+lNFLQodreQ8EDyx6Mg6Ynm6UUDGzYYjx8OoFaeC2I8vBEc2 ts+SDO2bJPu+qJcJXPf4dEml+Gh4KsESx4xeu+sqjLYeMnJ2lJK90VKrTcjhYS4GW0 DK1dbKiz+rEIRAjCyTp9TH3OfUL6RAZ3ntGWbBu4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/gcs-13)] aarch64: Add __builtin_aarch64_chkfeat tests X-Act-Checkin: gcc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/vendors/ARM/heads/gcs-13 X-Git-Oldrev: 8e623cab64d6b4b2d18ab8c3983ec4cca723cfe8 X-Git-Newrev: 983296123d4f63983b079c2def18e22288590e13 Message-Id: <20240214153709.36A1D385EC49@sourceware.org> Date: Wed, 14 Feb 2024 15:37:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:983296123d4f63983b079c2def18e22288590e13 commit 983296123d4f63983b079c2def18e22288590e13 Author: Szabolcs Nagy Date: Fri Jun 2 16:15:25 2023 +0100 aarch64: Add __builtin_aarch64_chkfeat tests gcc/testsuite/ChangeLog: * gcc.target/aarch64/chkfeat-1.c: New test. * gcc.target/aarch64/chkfeat-2.c: New test. Diff: --- gcc/testsuite/gcc.target/aarch64/chkfeat-1.c | 75 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/aarch64/chkfeat-2.c | 15 ++++++ 2 files changed, 90 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/chkfeat-1.c b/gcc/testsuite/gcc.target/aarch64/chkfeat-1.c new file mode 100644 index 000000000000..2fae81e740fa --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/chkfeat-1.c @@ -0,0 +1,75 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbranch-protection=none" } */ +/* { dg-final { check-function-bodies "**" "" "" } } */ + +/* +**foo1: +** mov x16, 1 +** hint 40 // chkfeat x16 +** mov x0, x16 +** ret +*/ +unsigned long long +foo1 (void) +{ + return __builtin_aarch64_chkfeat (1); +} + +/* +**foo2: +** mov x16, 1 +** movk x16, 0x5678, lsl 32 +** movk x16, 0x1234, lsl 48 +** hint 40 // chkfeat x16 +** mov x0, x16 +** ret +*/ +unsigned long long +foo2 (void) +{ + return __builtin_aarch64_chkfeat (0x1234567800000001); +} + +/* +**foo3: +** mov x16, x0 +** hint 40 // chkfeat x16 +** mov x0, x16 +** ret +*/ +unsigned long long +foo3 (unsigned long long x) +{ + return __builtin_aarch64_chkfeat (x); +} + +/* +**foo4: +** ldr x16, \[x0\] +** hint 40 // chkfeat x16 +** str x16, \[x0\] +** ret +*/ +void +foo4 (unsigned long long *p) +{ + *p = __builtin_aarch64_chkfeat (*p); +} + +/* +**foo5: +** mov x16, 1 +** hint 40 // chkfeat x16 +** cmp x16, 0 +**( +** csel w0, w1, w0, eq +**| +** csel w0, w0, w1, ne +**) +** ret +*/ +int +foo5 (int x, int y) +{ + return __builtin_aarch64_chkfeat (1) ? x : y; +} diff --git a/gcc/testsuite/gcc.target/aarch64/chkfeat-2.c b/gcc/testsuite/gcc.target/aarch64/chkfeat-2.c new file mode 100644 index 000000000000..682524e244fc --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/chkfeat-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times {hint\t40 // chkfeat x16} 2 } } */ + +void bar (void); + +/* Extern call may change enabled HW features. */ +unsigned long long +foo (void) +{ + unsigned long long a = __builtin_aarch64_chkfeat (1); + bar (); + unsigned long long b = __builtin_aarch64_chkfeat (1); + return a + b; +}