From: Craig Topper Date: Fri, 13 Jul 2018 21:03:43 +0000 (+0000) Subject: [X86][FastISel] Add EVEX support to sitofp handling. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6cdf32fe6d68564888292941823af77c869d825;p=llvm [X86][FastISel] Add EVEX support to sitofp handling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337045 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index d65d81b17f4..acbf01b3318 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -2417,8 +2417,9 @@ bool X86FastISel::X86SelectSIToFP(const Instruction *I) { if (!Subtarget->hasAVX()) return false; - Type *InTy = I->getOperand(0)->getType(); - if (!InTy->isIntegerTy(32) && !InTy->isIntegerTy(64)) + // TODO: We could sign extend narrower types. + MVT SrcVT = TLI.getSimpleValueType(DL, I->getOperand(0)->getType()); + if (SrcVT != MVT::i32 && SrcVT != MVT::i64) return false; // Select integer to float/double conversion. @@ -2426,20 +2427,28 @@ bool X86FastISel::X86SelectSIToFP(const Instruction *I) { if (OpReg == 0) return false; - const TargetRegisterClass *RC = nullptr; unsigned Opcode; + static const uint16_t CvtOpc[2][2][2] = { + { { X86::VCVTSI2SSrr, X86::VCVTSI642SSrr }, + { X86::VCVTSI2SDrr, X86::VCVTSI642SDrr } }, + { { X86::VCVTSI2SSZrr, X86::VCVTSI642SSZrr }, + { X86::VCVTSI2SDZrr, X86::VCVTSI642SDZrr } }, + }; + bool HasAVX512 = Subtarget->hasAVX512(); + bool Is64Bit = SrcVT == MVT::i64; + if (I->getType()->isDoubleTy()) { // sitofp int -> double - Opcode = InTy->isIntegerTy(64) ? X86::VCVTSI642SDrr : X86::VCVTSI2SDrr; - RC = &X86::FR64RegClass; + Opcode = CvtOpc[HasAVX512][1][Is64Bit]; } else if (I->getType()->isFloatTy()) { // sitofp int -> float - Opcode = InTy->isIntegerTy(64) ? X86::VCVTSI642SSrr : X86::VCVTSI2SSrr; - RC = &X86::FR32RegClass; + Opcode = CvtOpc[HasAVX512][0][Is64Bit]; } else return false; + MVT DstVT = TLI.getValueType(DL, I->getType()).getSimpleVT(); + const TargetRegisterClass *RC = TLI.getRegClassFor(DstVT); unsigned ImplicitDefReg = createResultReg(RC); BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(TargetOpcode::IMPLICIT_DEF), ImplicitDefReg); diff --git a/test/CodeGen/X86/fast-isel-int-float-conversion-x86-64.ll b/test/CodeGen/X86/fast-isel-int-float-conversion-x86-64.ll index 6cca2101456..469b5e5b4ba 100644 --- a/test/CodeGen/X86/fast-isel-int-float-conversion-x86-64.ll +++ b/test/CodeGen/X86/fast-isel-int-float-conversion-x86-64.ll @@ -1,6 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+sse2 -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=ALL --check-prefix=SSE2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+avx -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX +; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+avx512f -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX define double @long_to_double_rr(i64 %a) { diff --git a/test/CodeGen/X86/fast-isel-int-float-conversion.ll b/test/CodeGen/X86/fast-isel-int-float-conversion.ll index 6c8df695749..fbaa86a2e2c 100644 --- a/test/CodeGen/X86/fast-isel-int-float-conversion.ll +++ b/test/CodeGen/X86/fast-isel-int-float-conversion.ll @@ -1,8 +1,10 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+sse2 -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=SSE2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+avx -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=AVX +; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+avx512f -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=AVX ; RUN: llc -mtriple=i686-unknown-unknown -mcpu=generic -mattr=+sse2 -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=SSE2_X86 ; RUN: llc -mtriple=i686-unknown-unknown -mcpu=generic -mattr=+avx -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=AVX_X86 +; RUN: llc -mtriple=i686-unknown-unknown -mcpu=generic -mattr=+avx512f -fast-isel --fast-isel-abort=1 < %s | FileCheck %s --check-prefix=AVX_X86 define double @int_to_double_rr(i32 %a) {