diff options
author | Maciej W. Rozycki <macro@orcam.me.uk> | 2024-09-15 15:28:18 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@orcam.me.uk> | 2024-09-15 15:28:18 +0100 |
commit | c26846ab066fc6e3a2843cbadfe159e0c4a1cc21 (patch) | |
tree | d04790008bec76bbdd70b7e2a30d3d57a070aff7 | |
parent | 248f96fba6fd0db5f56d1133a6655a15954b648f (diff) | |
download | binutils-c26846ab066fc6e3a2843cbadfe159e0c4a1cc21.zip binutils-c26846ab066fc6e3a2843cbadfe159e0c4a1cc21.tar.gz binutils-c26846ab066fc6e3a2843cbadfe159e0c4a1cc21.tar.bz2 |
MIPS/GAS: Discard redundant instruction from DDIV/DREM macros
A sequence such as:
li at,-1
bne xx,at,0f
li at,1
dsll32 at,at,0x1f
is produced in the expansion of the DDIV and DREM assembly macros, where
a redundant `li at,1' instruction is used to load an intermediate value
of 1 into $at, which is then left-shifted by 63 with `dsll32 at,at,0x1f'
yielding 0x8000000000000000. However this value likewise results from
left-shifting the value of -1, already present in $at at this point.
Remove the extraneous instruction then, shortening the sequence emitted.
Adjust dumps in the testsuite accordingly.
-rw-r--r-- | gas/config/tc-mips.c | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/div64-trap.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/div64.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips-compact.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips-insn32.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips-noinsn32.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips-trap.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips@div64-trap.d | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/micromips@div64.d | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips3@div64-trap.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips3@div64.d | 3 |
12 files changed, 5 insertions, 29 deletions
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 28d3ed8..576ef1f 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -10831,13 +10831,10 @@ macro (struct mips_cl_insn *ip, char *str) if (mips_opts.micromips) micromips_label_expr (&label_expr); else - label_expr.X_add_number = (mips_use_trap () - ? (dbl ? 12 : 8) : (dbl ? 20 : 16)); + label_expr.X_add_number = mips_use_trap () ? 8 : 16; macro_build (&label_expr, "bne", "s,t,p", op[2], AT); if (dbl) { - expr1.X_add_number = 1; - load_register (AT, &expr1, dbl); macro_build (NULL, "dsll32", SHFT_FMT, AT, AT, 31); } else diff --git a/gas/testsuite/gas/mips/div64-trap.d b/gas/testsuite/gas/mips/div64-trap.d index eab1975..48e4947 100644 --- a/gas/testsuite/gas/mips/div64-trap.d +++ b/gas/testsuite/gas/mips/div64-trap.d @@ -11,8 +11,7 @@ Disassembly of section \.text: [0-9a-f]+ <[^>]*> 00c001f4 teq a2,zero,0x7 [0-9a-f]+ <[^>]*> 00a6001e ddiv zero,a1,a2 [0-9a-f]+ <[^>]*> 2401ffff li at,-1 -[0-9a-f]+ <[^>]*> 14c10003 bne a2,at,[0-9a-f]+ <[^>]*> -[0-9a-f]+ <[^>]*> 24010001 li at,1 +[0-9a-f]+ <[^>]*> 14c10002 bne a2,at,[0-9a-f]+ <[^>]*> [0-9a-f]+ <[^>]*> 00010ffc dsll32 at,at,0x1f [0-9a-f]+ <[^>]*> 00a101b4 teq a1,at,0x6 [0-9a-f]+ <[^>]*> 00002012 mflo a0 diff --git a/gas/testsuite/gas/mips/div64.d b/gas/testsuite/gas/mips/div64.d index 926cdb6..2c6b343 100644 --- a/gas/testsuite/gas/mips/div64.d +++ b/gas/testsuite/gas/mips/div64.d @@ -11,8 +11,7 @@ Disassembly of section \.text: [0-9a-f]+ <[^>]*> 00a6001e ddiv zero,a1,a2 [0-9a-f]+ <[^>]*> 0007000d break 0x7 [0-9a-f]+ <[^>]*> 2401ffff li at,-1 -[0-9a-f]+ <[^>]*> 14c10005 bne a2,at,[0-9a-f]+ <[^>]*> -[0-9a-f]+ <[^>]*> 24010001 li at,1 +[0-9a-f]+ <[^>]*> 14c10004 bne a2,at,[0-9a-f]+ <[^>]*> [0-9a-f]+ <[^>]*> 00010ffc dsll32 at,at,0x1f [0-9a-f]+ <[^>]*> 14a10002 bne a1,at,[0-9a-f]+ <[^>]*> [0-9a-f]+ <[^>]*> 00000000 nop diff --git a/gas/testsuite/gas/mips/micromips-compact.d b/gas/testsuite/gas/mips/micromips-compact.d index 34f6186..ca3451b 100644 --- a/gas/testsuite/gas/mips/micromips-compact.d +++ b/gas/testsuite/gas/mips/micromips-compact.d @@ -6523,7 +6523,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b424 fffe bne a0,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -6960,7 +6959,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -6978,7 +6976,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b43f fffe bne ra,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* diff --git a/gas/testsuite/gas/mips/micromips-insn32.d b/gas/testsuite/gas/mips/micromips-insn32.d index f4282ff..e785134 100644 --- a/gas/testsuite/gas/mips/micromips-insn32.d +++ b/gas/testsuite/gas/mips/micromips-insn32.d @@ -6547,7 +6547,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b424 fffe bne a0,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -6984,7 +6983,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -7002,7 +7000,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b43f fffe bne ra,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* diff --git a/gas/testsuite/gas/mips/micromips-noinsn32.d b/gas/testsuite/gas/mips/micromips-noinsn32.d index 75bfaf7..3fa9a06 100644 --- a/gas/testsuite/gas/mips/micromips-noinsn32.d +++ b/gas/testsuite/gas/mips/micromips-noinsn32.d @@ -6524,7 +6524,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b424 fffe bne a0,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -6961,7 +6960,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -6979,7 +6977,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b43f fffe bne ra,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* diff --git a/gas/testsuite/gas/mips/micromips-trap.d b/gas/testsuite/gas/mips/micromips-trap.d index 68f5a02..0be6e28 100644 --- a/gas/testsuite/gas/mips/micromips-trap.d +++ b/gas/testsuite/gas/mips/micromips-trap.d @@ -6526,7 +6526,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b424 fffe bne a0,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: 0023 603c teq v1,at,0x6 @@ -6928,7 +6927,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: 0020 603c teq zero,at,0x6 @@ -6939,7 +6937,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b43f fffe bne ra,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: 0020 603c teq zero,at,0x6 diff --git a/gas/testsuite/gas/mips/micromips.d b/gas/testsuite/gas/mips/micromips.d index 86511b9..4d96510 100644 --- a/gas/testsuite/gas/mips/micromips.d +++ b/gas/testsuite/gas/mips/micromips.d @@ -6602,7 +6602,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b424 fffe bne a0,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -7039,7 +7038,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b423 fffe bne v1,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* @@ -7057,7 +7055,6 @@ Disassembly of section \.text: [ 0-9a-f]+: 3020 ffff li at,-1 [ 0-9a-f]+: b43f fffe bne ra,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* -[ 0-9a-f]+: 3020 0001 li at,1 [ 0-9a-f]+: 5821 f808 dsll32 at,at,0x1f [ 0-9a-f]+: b420 fffe bne zero,at,[0-9a-f]+ <.*\+0x[0-9a-f]+> [ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .* diff --git a/gas/testsuite/gas/mips/micromips@div64-trap.d b/gas/testsuite/gas/mips/micromips@div64-trap.d index e4e5e68..6839401 100644 --- a/gas/testsuite/gas/mips/micromips@div64-trap.d +++ b/gas/testsuite/gas/mips/micromips@div64-trap.d @@ -13,7 +13,6 @@ Disassembly of section \.text: [0-9a-f]+ <[^>]*> 3020 ffff li at,-1 [0-9a-f]+ <[^>]*> b426 fffe bne a2,at,[0-9a-f]+ <[^>]*> [0-9a-f]+: R_MICROMIPS_PC16_S1 \.L\^_0 -[0-9a-f]+ <[^>]*> 3020 0001 li at,1 [0-9a-f]+ <[^>]*> 5821 f808 dsll32 at,at,0x1f [0-9a-f]+ <[^>]*> 0025 603c teq a1,at,0x6 [0-9a-f]+ <\.L\^_0> 4644 mflo a0 diff --git a/gas/testsuite/gas/mips/micromips@div64.d b/gas/testsuite/gas/mips/micromips@div64.d index 07abe64..af7fc2c 100644 --- a/gas/testsuite/gas/mips/micromips@div64.d +++ b/gas/testsuite/gas/mips/micromips@div64.d @@ -15,7 +15,6 @@ Disassembly of section \.text: [0-9a-f]+ <\.L\^_0> 3020 ffff li at,-1 [0-9a-f]+ <[^>]*> b426 fffe bne a2,at,[0-9a-f]+ <[^>]*> [0-9a-f]+: R_MICROMIPS_PC16_S1 \.L\^_1 -[0-9a-f]+ <[^>]*> 3020 0001 li at,1 [0-9a-f]+ <[^>]*> 5821 f808 dsll32 at,at,0x1f [0-9a-f]+ <[^>]*> b425 fffe bne a1,at,[0-9a-f]+ <[^>]*> [0-9a-f]+: R_MICROMIPS_PC16_S1 \.L\^_1 diff --git a/gas/testsuite/gas/mips/mips3@div64-trap.d b/gas/testsuite/gas/mips/mips3@div64-trap.d index 568fbd4..33196f38 100644 --- a/gas/testsuite/gas/mips/mips3@div64-trap.d +++ b/gas/testsuite/gas/mips/mips3@div64-trap.d @@ -11,8 +11,7 @@ Disassembly of section \.text: [0-9a-f]+ <[^>]*> 00c001f4 teq a2,zero,0x7 [0-9a-f]+ <[^>]*> 00a6001e ddiv zero,a1,a2 [0-9a-f]+ <[^>]*> 2401ffff li at,-1 -[0-9a-f]+ <[^>]*> 14c10003 bne a2,at,[0-9a-f]+ <[^>]*> -[0-9a-f]+ <[^>]*> 24010001 li at,1 +[0-9a-f]+ <[^>]*> 14c10002 bne a2,at,[0-9a-f]+ <[^>]*> [0-9a-f]+ <[^>]*> 00010ffc dsll32 at,at,0x1f [0-9a-f]+ <[^>]*> 00a101b4 teq a1,at,0x6 [0-9a-f]+ <[^>]*> 00002012 mflo a0 diff --git a/gas/testsuite/gas/mips/mips3@div64.d b/gas/testsuite/gas/mips/mips3@div64.d index cbb0af4..ec0f03e 100644 --- a/gas/testsuite/gas/mips/mips3@div64.d +++ b/gas/testsuite/gas/mips/mips3@div64.d @@ -12,8 +12,7 @@ Disassembly of section \.text: [0-9a-f]+ <[^>]*> 00a6001e ddiv zero,a1,a2 [0-9a-f]+ <[^>]*> 0007000d break 0x7 [0-9a-f]+ <[^>]*> 2401ffff li at,-1 -[0-9a-f]+ <[^>]*> 14c10005 bne a2,at,[0-9a-f]+ <[^>]*> -[0-9a-f]+ <[^>]*> 24010001 li at,1 +[0-9a-f]+ <[^>]*> 14c10004 bne a2,at,[0-9a-f]+ <[^>]*> [0-9a-f]+ <[^>]*> 00010ffc dsll32 at,at,0x1f [0-9a-f]+ <[^>]*> 14a10002 bne a1,at,[0-9a-f]+ <[^>]*> [0-9a-f]+ <[^>]*> 00000000 nop |