[PATCH] [X86][FastIsel] Teach how to select scalar integer to float/double conversions.

Quentin Colombet qcolombet at apple.com
Tue Feb 17 15:30:24 PST 2015


Please commit!


================
Comment at: lib/Target/X86/X86FastISel.cpp:2042
@@ +2041,3 @@
+  const MCInstrDesc &II = TII.get(Opcode);
+  OpReg = constrainOperandRegClass(II, OpReg, (HasAVX ? 2 : 1));
+  
----------------
andreadb wrote:
> qcolombet wrote:
> > Should be just 1 instead of (HasAVX …).
> > 
> > Indeed, OpReg is the equivalent of the first operand for the description of the CVT. The fact that you will insert an implicit def is orthogonal so you do not have to account for that when doing the query.
> I tried to just pass 1 instead of checking if the target HasAVX. However, the code generated is wrong..
> For example, with that change, I get the following assembly:
> 
> int_to_double_rr:
>         vmovd   %edi, %xmm1
>         vcvtsi2sd       %xmm1, %xmm0, %xmm0
> 
> int_to_float_rr:
>         vmovd   %edi, %xmm1
>         vcvtsi2ssl      %xmm1, %xmm0, %xmm0
>         retq
> 
> The reason why I added a check for AVX is because OpReg is expected to be the last input operand. According to X86InstrSSE.td, OpReg should be the second operand for the AVX variant. If I pass index 2 on AVX, then I get the correct results. This seems to suggest that we have to account for the IMPLICIT_DEF when doing the query.
Indeed!

I forgot that the AVX variant copied the first operand.

Sorry for the noise!

http://reviews.llvm.org/D7698

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list