]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Always emit MOVSBL instead of MOVSBW [PR125636]
authorUros Bizjak <ubizjak@gmail.com>
Tue, 9 Jun 2026 14:48:56 +0000 (16:48 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Tue, 9 Jun 2026 17:20:27 +0000 (19:20 +0200)
Use MOVSBL instead of MOVSBW for QImode-to-HImode sign extension to avoid
a 16-bit partial register write and to eliminate 0x66 operand size prefix.

PR target/125636

gcc/ChangeLog:

* config/i386/i386.md (extendqihi2): Use movsbl instead of movsbw.
Adjust the destination operand to use %k0 and update the mode
attribute accordingly.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr89954.c: Update assembler scan
directives to expect movsbl instead of movsbw.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr89954.c

index 223fdb538cfa58dbce195cafc315901295c62b79..8db5d3b015265b2e3f2508b0924a68aba343417f 100644 (file)
     case 0:
       return "{cbtw|cbw}";
     default:
-      return "movs{bw|x}\t{%1, %0|%0, %1}";
+      return "movs{bl|x}\t{%1, %k0|%k0, %1}";
     }
 }
   [(set_attr "type" "imovx")
-   (set_attr "mode" "HI")
+   (set_attr "mode" "HI,SI")
    (set (attr "prefix_0f")
      ;; movsx is short decodable while cwtl is vector decoded.
      (if_then_else (and (eq_attr "cpu" "!k6")
index c1e9f3a9562559153ef573124b7f89e4471498c5..99523903313eb688cf2fa9ad6c812c9af495ed1f 100644 (file)
@@ -36,8 +36,7 @@ long long sext_xorlq (void) { return al ^ -4; }
 
 #endif
 
-/* { dg-final { scan-assembler-times "movsbw" 3 } } */
-/* { dg-final { scan-assembler-times "movsbl" 3 } } */
+/* { dg-final { scan-assembler-times "movsbl" 6 } } */
 /* { dg-final { scan-assembler-times "movswl" 3 } } */
 
 /* { dg-final { scan-assembler-times "movsbq" 3 { target { ! ia32 } } } } */