summaryrefslogtreecommitdiff
path: root/gcc/config/arm/constraints.md
diff options
context:
space:
mode:
authorMatthew Malcomson <matthew.malcomson@arm.com>2019-04-09 11:39:59 +0000
committerMatthew Malcomson <matmal01@gcc.gnu.org>2019-04-09 11:39:59 +0000
commite009dfb32037f94447f0547a3930ecccd7fabe37 (patch)
treee22eb2b914b8268d511c3cec3f6788fba44ac71d /gcc/config/arm/constraints.md
parent765f8786cf6e22aa6309f321f0afd8e7dc79b4bb (diff)
downloadgcc-e009dfb32037f94447f0547a3930ecccd7fabe37.tar.gz
Hi there,
The "*neon_mov<mode>" patterns for 128 bit sized quantities uses the "Dn" constraint to match vmov.f32 and vmov.i<vec-width> patterns. This constraint boils down to using the `neon_immediate_valid` function. Once the constraint has matched, the output C statement asserts that function passes. The output C statement calls `neon_immediate_valid` with the mode taken from the iterator, while the constraint takes the mode from the operand. This can cause a discrepency when the operand is a CONST_INT, as the constraint passes VOIDmode which `neon_immediate_valid` treats as DImode, while the C statement passes the mode of the iterator which can be TImode. When this happens, the `neon_immediate_valid` can fail in the second call (if e.g. the CONST_INT is a valid immediate in DImode but not TImode) which would trigger the assertion. The testcase added with this patch triggers this when compiled with an arm cross compiler using the command line below. gcc -march=armv8-a -c neon-immediate-timode.c -O1 -mfloat-abi=hard -mfpu=neon-fp-armv8 This patch splits the original "Dn" constraint into three new constraints, "DN" for TImode CONST_INT, "Dn" for DImode CONST_INT, and "Dm" for CONST_VECTOR. Splitting things up this way requires using one extra alternative in the "*neon_mov<mode>" patterns, but makes it clear from the constraint what mode is being used. We also remove the behaviour of treating VOIDmode as DImode in `neon_valid_immediate` since the original "Dn" constraint was the only place that functionality was used. VOIDmode is now never passed to that function. An assertion has been added to the function to ensure this problem is caught earlier on. Bootstrapped on arm-none-linux-gnueabihf Regtested on cross-compiler arm-none-eabi gcc/ChangeLog: 2019-04-09 Matthew Malcomson <matthew.malcomson@arm.com> PR target/90024 * config/arm/arm.c (neon_valid_immediate): Disallow VOIDmode parameter. * config/arm/constraints.md (Dm, DN, Dn): Split previous Dn constraint into three. * config/arm/neon.md (*neon_mov<mode>): Account for TImode and DImode differences directly. (*smax<mode>3_neon, vashl<mode>3, vashr<mode>3_imm): Use Dm constraint. gcc/testsuite/ChangeLog: 2019-04-09 Matthew Malcomson <matthew.malcomson@arm.com> PR target/90024 * gcc.dg/torture/neon-immediate-timode.c: New test. From-SVN: r270226
Diffstat (limited to 'gcc/config/arm/constraints.md')
-rw-r--r--gcc/config/arm/constraints.md26
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/config/arm/constraints.md b/gcc/config/arm/constraints.md
index 57ec0639622..d4a4c5967ae 100644
--- a/gcc/config/arm/constraints.md
+++ b/gcc/config/arm/constraints.md
@@ -31,8 +31,8 @@
;; 'H' was previously used for FPA.
;; The following multi-letter normal constraints have been used:
-;; in ARM/Thumb-2 state: Da, Db, Dc, Dd, Dn, Dl, DL, Do, Dv, Dy, Di, Dt, Dp,
-;; Dz, Tu
+;; in ARM/Thumb-2 state: Da, Db, Dc, Dd, Dn, DN, Dm, Dl, DL, Do, Dv, Dy, Di,
+;; Dt, Dp, Dz, Tu
;; in Thumb-1 state: Pa, Pb, Pc, Pd, Pe
;; in Thumb-2 state: Ha, Pj, PJ, Ps, Pt, Pu, Pv, Pw, Px, Py, Pz
;; in all states: Pf
@@ -298,14 +298,28 @@
(and (match_code "const_double,const_int")
(match_test "TARGET_32BIT && arm_const_double_by_immediates (op)")))
-(define_constraint "Dn"
+(define_constraint "Dm"
"@internal
- In ARM/Thumb-2 state a const_vector or const_int which can be loaded with a
- Neon vmov immediate instruction."
- (and (match_code "const_vector,const_int")
+ In ARM/Thumb-2 state a const_vector which can be loaded with a Neon vmov
+ immediate instruction."
+ (and (match_code "const_vector")
(match_test "TARGET_32BIT
&& imm_for_neon_mov_operand (op, GET_MODE (op))")))
+(define_constraint "Dn"
+ "@internal
+ In ARM/Thumb-2 state a DImode const_int which can be loaded with a Neon vmov
+ immediate instruction."
+ (and (match_code "const_int")
+ (match_test "TARGET_32BIT && imm_for_neon_mov_operand (op, DImode)")))
+
+(define_constraint "DN"
+ "@internal
+ In ARM/Thumb-2 state a TImode const_int which can be loaded with a Neon vmov
+ immediate instruction."
+ (and (match_code "const_int")
+ (match_test "TARGET_32BIT && imm_for_neon_mov_operand (op, TImode)")))
+
(define_constraint "Dl"
"@internal
In ARM/Thumb-2 state a const_vector which can be used with a Neon vorr or