[v1,1/4] LoongArch: Add tests of -mstrict-align option.

Message ID 20230906104307.37244-2-chenxiaolong@loongson.cn
State Accepted
Headers
Series Add Loongson SX/ASX instruction support to LoongArch |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

chenxiaolong Sept. 6, 2023, 10:43 a.m. UTC
  gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/strict-align.c: New test.
---
 gcc/testsuite/gcc.target/loongarch/strict-align.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/loongarch/strict-align.c
  

Comments

Xi Ruoyao Sept. 6, 2023, 11:10 a.m. UTC | #1
On Wed, 2023-09-06 at 18:43 +0800, Xiaolong Chen wrote:
> gcc/testsuite/ChangeLog:
> 
>         * gcc.target/loongarch/strict-align.c: New test.

A question: is there really a CPU model with LSX/LASX but without
unaligned access support?  If not I think we'd just reject -mstrict-
align -mlsx.

Currently Glibc assumes if LSX is available then unaligned access must
be available too.

> ---
>  gcc/testsuite/gcc.target/loongarch/strict-align.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/loongarch/strict-align.c
> 
> diff --git a/gcc/testsuite/gcc.target/loongarch/strict-align.c
> b/gcc/testsuite/gcc.target/loongarch/strict-align.c
> new file mode 100644
> index 00000000000..bcad2b84f68
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/loongarch/strict-align.c
> @@ -0,0 +1,13 @@
> +/* { dg-do compile } */
> +/* { dg-options "-Ofast -mstrict-align -mlasx" } */
> +/* { dg-final { scan-assembler-not "vfadd.s" } } */
> +
> +void
> +foo (float* restrict x, float* restrict y)
> +{
> +  x[0] = x[0] + y[0];
> +  x[1] = x[1] + y[1];
> +  x[2] = x[2] + y[2];
> +  x[3] = x[3] + y[3];
> +}
> +
  
chenglulu Sept. 7, 2023, 1:28 a.m. UTC | #2
在 2023/9/6 下午7:10, Xi Ruoyao 写道:
> On Wed, 2023-09-06 at 18:43 +0800, Xiaolong Chen wrote:
>> gcc/testsuite/ChangeLog:
>>
>>          * gcc.target/loongarch/strict-align.c: New test.
> A question: is there really a CPU model with LSX/LASX but without
> unaligned access support?  If not I think we'd just reject -mstrict-
> align -mlsx.
>
> Currently Glibc assumes if LSX is available then unaligned access must
> be available too.

This is not a question of support or unsupport, the original intention 
is to need to naturally align memory access to improve performance after 
enabling LSX, but this part of the code has not been ported to the main 
branch, so we will submit this test example after adding the 
corresponding function.

Thanks!

>
>> ---
>>   gcc/testsuite/gcc.target/loongarch/strict-align.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>   create mode 100644 gcc/testsuite/gcc.target/loongarch/strict-align.c
>>
>> diff --git a/gcc/testsuite/gcc.target/loongarch/strict-align.c
>> b/gcc/testsuite/gcc.target/loongarch/strict-align.c
>> new file mode 100644
>> index 00000000000..bcad2b84f68
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/loongarch/strict-align.c
>> @@ -0,0 +1,13 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-Ofast -mstrict-align -mlasx" } */
>> +/* { dg-final { scan-assembler-not "vfadd.s" } } */
>> +
>> +void
>> +foo (float* restrict x, float* restrict y)
>> +{
>> +  x[0] = x[0] + y[0];
>> +  x[1] = x[1] + y[1];
>> +  x[2] = x[2] + y[2];
>> +  x[3] = x[3] + y[3];
>> +}
>> +
  

Patch

diff --git a/gcc/testsuite/gcc.target/loongarch/strict-align.c b/gcc/testsuite/gcc.target/loongarch/strict-align.c
new file mode 100644
index 00000000000..bcad2b84f68
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/strict-align.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile } */
+/* { dg-options "-Ofast -mstrict-align -mlasx" } */
+/* { dg-final { scan-assembler-not "vfadd.s" } } */
+
+void
+foo (float* restrict x, float* restrict y)
+{
+  x[0] = x[0] + y[0];
+  x[1] = x[1] + y[1];
+  x[2] = x[2] + y[2];
+  x[3] = x[3] + y[3];
+}
+