https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125636
--- Comment #12 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #11)
> Comment on attachment 64650 [details]
> gcc/testsuite/gcc.target/i386/pr125636.c
>
> >short
> >test_sign_extend (unsigned char *p)
>
> You want "signed char" here.
>
> The patch can then be as simple as:
>
> --cut here--
> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> index 223fdb538cf..8db5d3b0152 100644
> --- a/gcc/config/i386/i386.md
> +++ b/gcc/config/i386/i386.md
> @@ -5303,11 +5303,11 @@ (define_insn "extendqihi2"
> 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")
> --cut here--
This is the patch which I was thinking of when I wrote comment #4.