Commit d4febc7
committed
aarch64: Don't emit invalid zero/sign-extend syntax
Given the following C function:
double *f(double *p, unsigned x)
{
return p + x;
}
prior to this patch, GCC at -O2 would generate:
f:
add x0, x0, x1, uxtw 3
ret
but this add instruction uses architecturally-invalid syntax: the width
of the third operand conflicts with the width of the extension
specifier. The third operand is only permitted to be an x register when
the extension specifier is (u|s)xtx.
This instruction, and analogous insns for adds, sub, subs, and cmp, are
rejected by clang, but accepted by binutils. Assembling and
disassembling such an insn with binutils gives the architecturally-valid
version in the disassembly:
0: 8b214c00 add x0, x0, w1, uxtw gcc-mirror#3
This patch fixes several patterns in the AArch64 backend to use the
standard syntax as specified in the Arm ARM such that GCC's output can
be assembled by assemblers other than GAS.
---
gcc/ChangeLog:
* config/aarch64/aarch64.md
(*adds_<optab><ALLX:mode>_<GPI:mode>): Ensure extended operand
agrees with width of extension specifier.
(*subs_<optab><ALLX:mode>_<GPI:mode>): Likewise.
(*adds_<optab><ALLX:mode>_shift_<GPI:mode>): Likewise.
(*subs_<optab><ALLX:mode>_shift_<GPI:mode>): Likewise.
(*add_<optab><ALLX:mode>_<GPI:mode>): Likewise.
(*add_<optab><ALLX:mode>_shft_<GPI:mode>): Likewise.
(*add_uxt<mode>_shift2): Likewise.
(*sub_<optab><ALLX:mode>_<GPI:mode>): Likewise.
(*sub_<optab><ALLX:mode>_shft_<GPI:mode>): Likewise.
(*sub_uxt<mode>_shift2): Likewise.
(*cmp_swp_<optab><ALLX:mode>_reg<GPI:mode>): Likewise.
(*cmp_swp_<optab><ALLX:mode>_shft_<GPI:mode>): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/adds3.c: Fix test w.r.t. new syntax.
* gcc.target/aarch64/cmp.c: Likewise.
* gcc.target/aarch64/subs3.c: Likewise.
* gcc.target/aarch64/subsp.c: Likewise.
* gcc.target/aarch64/extend-syntax.c: New test.1 parent 931832a commit d4febc7
File tree
6 files changed
+137
-16
lines changed- gcc
- config/aarch64
- testsuite/gcc.target/aarch64
6 files changed
+137
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2383 | 2383 | | |
2384 | 2384 | | |
2385 | 2385 | | |
2386 | | - | |
| 2386 | + | |
2387 | 2387 | | |
2388 | 2388 | | |
2389 | 2389 | | |
| |||
2397 | 2397 | | |
2398 | 2398 | | |
2399 | 2399 | | |
2400 | | - | |
| 2400 | + | |
2401 | 2401 | | |
2402 | 2402 | | |
2403 | 2403 | | |
| |||
2415 | 2415 | | |
2416 | 2416 | | |
2417 | 2417 | | |
2418 | | - | |
| 2418 | + | |
2419 | 2419 | | |
2420 | 2420 | | |
2421 | 2421 | | |
| |||
2433 | 2433 | | |
2434 | 2434 | | |
2435 | 2435 | | |
2436 | | - | |
| 2436 | + | |
2437 | 2437 | | |
2438 | 2438 | | |
2439 | 2439 | | |
| |||
2549 | 2549 | | |
2550 | 2550 | | |
2551 | 2551 | | |
2552 | | - | |
| 2552 | + | |
2553 | 2553 | | |
2554 | 2554 | | |
2555 | 2555 | | |
| |||
2571 | 2571 | | |
2572 | 2572 | | |
2573 | 2573 | | |
2574 | | - | |
| 2574 | + | |
2575 | 2575 | | |
2576 | 2576 | | |
2577 | 2577 | | |
| |||
2819 | 2819 | | |
2820 | 2820 | | |
2821 | 2821 | | |
2822 | | - | |
| 2822 | + | |
2823 | 2823 | | |
2824 | 2824 | | |
2825 | 2825 | | |
| |||
3305 | 3305 | | |
3306 | 3306 | | |
3307 | 3307 | | |
3308 | | - | |
| 3308 | + | |
3309 | 3309 | | |
3310 | 3310 | | |
3311 | 3311 | | |
| |||
3328 | 3328 | | |
3329 | 3329 | | |
3330 | 3330 | | |
3331 | | - | |
| 3331 | + | |
3332 | 3332 | | |
3333 | 3333 | | |
3334 | 3334 | | |
| |||
3607 | 3607 | | |
3608 | 3608 | | |
3609 | 3609 | | |
3610 | | - | |
| 3610 | + | |
3611 | 3611 | | |
3612 | 3612 | | |
3613 | 3613 | | |
| |||
4054 | 4054 | | |
4055 | 4055 | | |
4056 | 4056 | | |
4057 | | - | |
| 4057 | + | |
4058 | 4058 | | |
4059 | 4059 | | |
4060 | 4060 | | |
| |||
4066 | 4066 | | |
4067 | 4067 | | |
4068 | 4068 | | |
4069 | | - | |
| 4069 | + | |
4070 | 4070 | | |
4071 | 4071 | | |
4072 | 4072 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
0 commit comments