[PATCH 1/5] x86: correct {,V}PEXTR{D,Q} optimization

Cui, Lili lili.cui@intel.com
Wed Sep 11 07:41:35 GMT 2024



> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Wednesday, September 11, 2024 3:20 PM
> To: Cui, Lili <lili.cui@intel.com>
> Cc: H.J. Lu <hjl.tools@gmail.com>; Binutils <binutils@sourceware.org>
> Subject: Re: [PATCH 1/5] x86: correct {,V}PEXTR{D,Q} optimization
> 
> On 11.09.2024 09:07, Cui, Lili wrote:
> >> -----Original Message-----
> >> From: Jan Beulich <jbeulich@suse.com>
> >> Sent: Friday, September 6, 2024 7:52 PM
> >>
> >> --- a/gas/config/tc-i386.c
> >> +++ b/gas/config/tc-i386.c
> >> @@ -5503,6 +5503,7 @@ optimize_encoding (void)
> >>        i.op[1].regs = i.op[2].regs;
> >>        i.types[1] = i.types[2];
> >>        i.flags[1] = i.flags[2];
> >> +      i.reloc[1] = i.reloc[2];
> >
> >
> >       /* Optimize: -O:
> >          pextrd $0, %xmmN, ...   -> movd %xmmN, ...
> >          pextrq $0, %xmmN, ...   -> movq %xmmN, ...
> >          vpextrd $0, %xmmN, ...  -> vmovd %xmmN, ...
> >          vpextrq $0, %xmmN, ...  -> vmovq %xmmN, ...
> >        */
> >
> > Jan, I have a question, why do you want to add the swap of i.reloc[] here
> (seems they are not related to reloc)? There is no swapping of i.reloc[] elsewhere
> in this function.
> 
> In most cases of what is being optimized there are no memory operands, or the
> number of operands total doesn't change. That's different here. And memory
> operands can come with a relocation, which needs to be kept associated with
> the correct operands.
> 
Yes, it is safer.

Thanks,
Lili.
> Jan



More information about the Binutils mailing list