https://gcc.gnu.org/g:093ffc54f4e5a8e1355e5d17fc6ee596983dbd65
commit r17-1454-g093ffc54f4e5a8e1355e5d17fc6ee596983dbd65 Author: Uros Bizjak <[email protected]> Date: Tue Jun 9 16:48:56 2026 +0200 i386: Always emit MOVSBL instead of MOVSBW [PR125636] 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. Diff: --- gcc/config/i386/i386.md | 4 ++-- gcc/testsuite/gcc.target/i386/pr89954.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 223fdb538cfa..8db5d3b01526 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -5303,11 +5303,11 @@ 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") diff --git a/gcc/testsuite/gcc.target/i386/pr89954.c b/gcc/testsuite/gcc.target/i386/pr89954.c index c1e9f3a95625..99523903313e 100644 --- a/gcc/testsuite/gcc.target/i386/pr89954.c +++ b/gcc/testsuite/gcc.target/i386/pr89954.c @@ -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 } } } } */
