]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
MIPS/GAS: Discard redundant instruction from DDIV/DREM macros
authorMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 15 Sep 2024 14:28:18 +0000 (15:28 +0100)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 15 Sep 2024 14:28:18 +0000 (15:28 +0100)
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.

12 files changed:
gas/config/tc-mips.c
gas/testsuite/gas/mips/div64-trap.d
gas/testsuite/gas/mips/div64.d
gas/testsuite/gas/mips/micromips-compact.d
gas/testsuite/gas/mips/micromips-insn32.d
gas/testsuite/gas/mips/micromips-noinsn32.d
gas/testsuite/gas/mips/micromips-trap.d
gas/testsuite/gas/mips/micromips.d
gas/testsuite/gas/mips/micromips@div64-trap.d
gas/testsuite/gas/mips/micromips@div64.d
gas/testsuite/gas/mips/mips3@div64-trap.d
gas/testsuite/gas/mips/mips3@div64.d

index 28d3ed839a4519555ee67ed4534ec369a4fe12a1..576ef1fb21f958f25dfa1a282a9658a02bc4828f 100644 (file)
@@ -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
index eab1975dd7a15f0172c0a26aa3f1f0063118f77d..48e4947b1bc3d27a9c5e680bf6cd1231deb0fbbf 100644 (file)
@@ -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
index 926cdb69031deadf135e7efe4703721a8ede0a13..2c6b343b694dad095730a1987f241b64e350777f 100644 (file)
@@ -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
index 34f61862faa34a8672c44c1733ff8948da64a822..ca3451b40aac0bc67310dca6d835cb8a41e81a4d 100644 (file)
@@ -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        .*
index f4282ffc51f25eeee9e03f35a395926446e95740..e7851345080d45274c04eef96fa436714c7f7825 100644 (file)
@@ -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        .*
index 75bfaf7db35199a46a2183fee5390ed3cf434547..3fa9a0613a1d9172f9605f054bd0040037750c73 100644 (file)
@@ -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        .*
index 68f5a028684dbf72fadb92cd6431e503dbc1249f..0be6e289848c1c4b41d74ab37bb83f065e348585 100644 (file)
@@ -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
 
index 86511b94cb47df1bd85b0855c81ab5be9a335b5d..4d965106321e61e7f7507a60919d1b11213fd737 100644 (file)
@@ -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        .*
index e4e5e680b86e045343cda4a89d3d0cc807eef65a..6839401d327f40a6cd193f7a0dc6c6f725bf462d 100644 (file)
@@ -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
index 07abe64799583bb8db7076d449424501b0940de6..af7fc2c08d4169af33b97c0d51a613f97076e1d5 100644 (file)
@@ -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
index 568fbd49e5e5cd2779eea40314a564afa44b35ad..33196f3837dbd31e53cb2fe5cee005f2c003eb24 100644 (file)
@@ -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
index cbb0af49e442c4b2bc0cc49539da083f366bf958..ec0f03ecf185a65cb14baef1397a4d3b22211dc7 100644 (file)
@@ -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