diff options
author | Kyrylo Tkachov <kyrylo.tkachov@arm.com> | 2020-04-01 13:53:05 +0100 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-04-10 09:46:28 +0200 |
commit | eac14e8065264abb7d3221f452337d4f21ea869e (patch) | |
tree | 341896ee07366a79fd52b43582ce719b3eb132be | |
parent | 86ad48d9196ce1401d7411f29645c28e16d4914b (diff) |
aarch64: Fix up aarch64_compare_and_swaphi pattern [PR94368]gcc-9_3_0-amp-1gcc-9_3_0-amp-branch
2020-04-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Backport from mainline
2020-03-31 Jakub Jelinek <jakub@redhat.com>
PR target/94368
* config/aarch64/constraints.md (Uph): New constraint.
* config/aarch64/atomics.md (cas_short_expected_imm): New mode attr.
(@aarch64_compare_and_swap<mode>): Use it instead of n in operand 2's
constraint.
* gcc.dg/pr94368.c: New test.
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/config/aarch64/atomics.md | 5 | ||||
-rw-r--r-- | gcc/config/aarch64/constraints.md | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr94368.c | 25 |
5 files changed, 54 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4890b6b55fef..ebe5e89001c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,17 @@ 2020-04-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Backport from mainline + 2020-03-31 Jakub Jelinek <jakub@redhat.com> + + PR target/94368 + * config/aarch64/constraints.md (Uph): New constraint. + * config/aarch64/atomics.md (cas_short_expected_imm): New mode attr. + (@aarch64_compare_and_swap<mode>): Use it instead of n in operand 2's + constraint. + +2020-04-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline 2020-01-17 Wilco Dijkstra <wdijkstr@arm.com> PR target/92692 diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md index 1458bc000959..590f82a4b14a 100644 --- a/gcc/config/aarch64/atomics.md +++ b/gcc/config/aarch64/atomics.md @@ -38,6 +38,8 @@ (define_mode_attr cas_short_expected_pred [(QI "aarch64_reg_or_imm") (HI "aarch64_plushi_operand")]) +(define_mode_attr cas_short_expected_imm + [(QI "n") (HI "Uph")]) (define_insn_and_split "@aarch64_compare_and_swap<mode>" [(set (reg:CC CC_REGNUM) ;; bool out @@ -47,7 +49,8 @@ (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory (set (match_dup 1) (unspec_volatile:SHORT - [(match_operand:SHORT 2 "<cas_short_expected_pred>" "rn") ;; expected + [(match_operand:SHORT 2 "<cas_short_expected_pred>" + "r<cas_short_expected_imm>") ;; expected (match_operand:SHORT 3 "aarch64_reg_or_zero" "rZ") ;; desired (match_operand:SI 4 "const_int_operand") ;; is_weak (match_operand:SI 5 "const_int_operand") ;; mod_s diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md index 21f9549e6608..73892b339c42 100644 --- a/gcc/config/aarch64/constraints.md +++ b/gcc/config/aarch64/constraints.md @@ -220,6 +220,13 @@ (and (match_code "const_int") (match_test "(unsigned) exact_log2 (ival) <= 4"))) +(define_constraint "Uph" + "@internal + A constraint that matches HImode integers zero extendable to + SImode plus_operand." + (and (match_code "const_int") + (match_test "aarch64_plushi_immediate (op, VOIDmode)"))) + (define_memory_constraint "Q" "A memory address which uses a single base register with no offset." (and (match_code "mem") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3b28ee321434..6a4c568f0bf7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,13 @@ 2020-04-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Backport from mainline + 2020-03-31 Jakub Jelinek <jakub@redhat.com> + + * gcc.dg/pr94368.c: New test. + +2020-04-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline 2019-09-19 Richard Henderson <richard.henderson@linaro.org> * gcc.target/aarch64/atomic-op-acq_rel.c: Use -mno-outline-atomics. diff --git a/gcc/testsuite/gcc.dg/pr94368.c b/gcc/testsuite/gcc.dg/pr94368.c new file mode 100644 index 000000000000..1267b8220983 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr94368.c @@ -0,0 +1,25 @@ +/* PR target/94368 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-fpic -O1 -fcommon" } */ + +int b, c, d, e, f, h; +short g; +int foo (int) __attribute__ ((__const__)); + +void +bar (void) +{ + while (1) + { + while (1) + { + __atomic_load_n (&e, 0); + if (foo (2)) + __sync_val_compare_and_swap (&c, 0, f); + b = 1; + if (h == e) + break; + } + __sync_val_compare_and_swap (&g, -1, f); + } +} |