forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH][GCC] arm: Fix MVE scalar shift intrinsics code-gen.
This patch modifies the MVE scalar shift RTL patterns. The current patterns have wrong constraints and predicates due to which the values returned from MVE scalar shift instructions are overwritten in the code-gen. example: $ cat x.c int32_t foo(int64_t acc, int shift) { return sqrshrl_sat48 (acc, shift); } Code-gen before applying this patch: $ arm-none-eabi-gcc -march=armv8.1-m.main+mve -mfloat-abi=hard -O2 -S $ cat x.s foo: push {r4, r5} sqrshrl r0, r1, gcc-mirror#48, r2 ----> (a) mov r0, r4 ----> (b) pop {r4, r5} bx lr Code-gen after applying this patch: foo: sqrshrl r0, r1, gcc-mirror#48, r2 bx lr In the current compiler the return value (r0) from sqrshrl (a) is getting overwritten by the mov statement (b). This patch fixes above issue. 2020-06-12 Srinath Parvathaneni <srinath.parvathaneni@arm.com> gcc/ * config/arm/mve.md (mve_uqrshll_sat<supf>_di): Correct the predicate and constraint of all the operands. (mve_sqrshrl_sat<supf>_di): Likewise. (mve_uqrshl_si): Likewise. (mve_sqrshr_si): Likewise. (mve_uqshll_di): Likewise. (mve_urshrl_di): Likewise. (mve_uqshl_si): Likewise. (mve_urshr_si): Likewise. (mve_sqshl_si): Likewise. (mve_srshr_si): Likewise. (mve_srshrl_di): Likewise. (mve_sqshll_di): Likewise. * config/arm/predicates.md (arm_low_register_operand): Define. gcc/testsuite/ * gcc.target/arm/mve/intrinsics/mve_scalar_shifts1.c: New test. * gcc.target/arm/mve/intrinsics/mve_scalar_shifts2.c: Likewise. * gcc.target/arm/mve/intrinsics/mve_scalar_shifts3.c: Likewise. * gcc.target/arm/mve/intrinsics/mve_scalar_shifts4.c: Likewise.
- Loading branch information
Showing
6 changed files
with
185 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
gcc/testsuite/gcc.target/arm/mve/intrinsics/mve_scalar_shifts1.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* { dg-do run } */ | ||
/* { dg-require-effective-target arm_v8_1m_mve_ok } */ | ||
/* { dg-options "-O2" } */ | ||
/* { dg-add-options arm_v8_1m_mve } */ | ||
|
||
#include "arm_mve.h" | ||
#include "stdio.h" | ||
#include <stdlib.h> | ||
|
||
void | ||
foo (int64_t acc, int shift) | ||
{ | ||
acc = sqrshrl_sat48 (acc, shift); | ||
if (acc != 16) | ||
abort(); | ||
acc = sqrshrl (acc, shift); | ||
if (acc != 2) | ||
abort(); | ||
} | ||
|
||
void | ||
foo1 (uint64_t acc, int shift) | ||
{ | ||
acc = uqrshll_sat48 (acc, shift); | ||
if (acc != 16) | ||
abort(); | ||
acc = uqrshll (acc, shift); | ||
if (acc != 128) | ||
abort(); | ||
} | ||
|
||
int main() | ||
{ | ||
int64_t acc = 128; | ||
uint64_t acc1 = 2; | ||
int shift = 3; | ||
foo (acc, shift); | ||
foo1 (acc1, shift); | ||
return 0; | ||
} |
35 changes: 35 additions & 0 deletions
35
gcc/testsuite/gcc.target/arm/mve/intrinsics/mve_scalar_shifts2.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* { dg-do run } */ | ||
/* { dg-require-effective-target arm_v8_1m_mve_ok } */ | ||
/* { dg-options "-O2" } */ | ||
/* { dg-add-options arm_v8_1m_mve } */ | ||
|
||
#include "arm_mve.h" | ||
#include "stdio.h" | ||
#include <stdlib.h> | ||
|
||
#define IMM 3 | ||
|
||
void | ||
foo (int64_t acc, uint64_t acc1) | ||
{ | ||
acc = sqshll (acc, IMM); | ||
if (acc != 128) | ||
abort(); | ||
acc = srshrl (acc, IMM); | ||
if (acc != 16) | ||
abort(); | ||
acc1 = uqshll (acc1, IMM); | ||
if (acc1 != 128) | ||
abort(); | ||
acc1 = urshrl (acc1, IMM); | ||
if (acc1 != 16) | ||
abort(); | ||
} | ||
|
||
int main() | ||
{ | ||
int64_t acc = 16; | ||
uint64_t acc1 = 16; | ||
foo (acc, acc1); | ||
return 0; | ||
} |
28 changes: 28 additions & 0 deletions
28
gcc/testsuite/gcc.target/arm/mve/intrinsics/mve_scalar_shifts3.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* { dg-do run } */ | ||
/* { dg-require-effective-target arm_v8_1m_mve_ok } */ | ||
/* { dg-options "-O2" } */ | ||
/* { dg-add-options arm_v8_1m_mve } */ | ||
|
||
#include "arm_mve.h" | ||
#include "stdio.h" | ||
#include <stdlib.h> | ||
|
||
void | ||
foo (int32_t acc, uint32_t acc1, int shift) | ||
{ | ||
acc = sqrshr (acc, shift); | ||
if (acc != 16) | ||
abort(); | ||
acc1 = uqrshl (acc1, shift); | ||
if (acc1 != 128) | ||
abort(); | ||
} | ||
|
||
int main() | ||
{ | ||
int32_t acc = 128; | ||
uint32_t acc1 = 16; | ||
int shift = 3; | ||
foo (acc, acc1, shift); | ||
return 0; | ||
} |
34 changes: 34 additions & 0 deletions
34
gcc/testsuite/gcc.target/arm/mve/intrinsics/mve_scalar_shifts4.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* { dg-do run } */ | ||
/* { dg-require-effective-target arm_v8_1m_mve_ok } */ | ||
/* { dg-options "-O2" } */ | ||
/* { dg-add-options arm_v8_1m_mve } */ | ||
|
||
#include "arm_mve.h" | ||
#include <stdlib.h> | ||
|
||
#define IMM 3 | ||
|
||
void | ||
foo (int32_t acc, uint32_t acc1) | ||
{ | ||
acc = sqshl (acc, IMM); | ||
if (acc != 128) | ||
abort(); | ||
acc = srshr (acc, IMM); | ||
if (acc != 16) | ||
abort(); | ||
acc1 = uqshl (acc1, IMM); | ||
if (acc1 != 128) | ||
abort(); | ||
acc1 = urshr (acc1, IMM); | ||
if (acc1 != 16) | ||
abort(); | ||
} | ||
|
||
int main() | ||
{ | ||
int32_t acc = 16; | ||
uint32_t acc1 = 16; | ||
foo (acc, acc1); | ||
return 0; | ||
} |