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

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Tue Feb 17 15:18:34 PST 2015


Hi Quentin,


================
Comment at: lib/Target/X86/X86FastISel.cpp:2042
@@ +2041,3 @@
+  const MCInstrDesc &II = TII.get(Opcode);
+  OpReg = constrainOperandRegClass(II, OpReg, (HasAVX ? 2 : 1));
+  
----------------
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.

http://reviews.llvm.org/D7698

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






More information about the llvm-commits mailing list