From 2c43c3b3329f662b7d23cc328c0404f12c3fb7f5 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 29 Oct 2017 02:50:31 +0000 Subject: [PATCH] [X86] Add AVX512 support to X86FastISel::X86SelectFPExt and X86FastISel::X86SelectFPTrunc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316856 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86FastISel.cpp | 16 ++++++++++++---- test/CodeGen/X86/fast-isel-fptrunc-fpext.ll | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 4c8decaf591..84264020dac 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -2473,9 +2473,13 @@ bool X86FastISel::X86SelectFPExtOrFPTrunc(const Instruction *I, bool X86FastISel::X86SelectFPExt(const Instruction *I) { if (X86ScalarSSEf64 && I->getType()->isDoubleTy() && I->getOperand(0)->getType()->isFloatTy()) { + bool HasAVX512 = Subtarget->hasAVX512(); // fpext from float to double. - unsigned Opc = Subtarget->hasAVX() ? X86::VCVTSS2SDrr : X86::CVTSS2SDrr; - return X86SelectFPExtOrFPTrunc(I, Opc, &X86::FR64RegClass); + unsigned Opc = + HasAVX512 ? X86::VCVTSS2SDZrr + : Subtarget->hasAVX() ? X86::VCVTSS2SDrr : X86::CVTSS2SDrr; + return X86SelectFPExtOrFPTrunc( + I, Opc, HasAVX512 ? &X86::FR64XRegClass : &X86::FR64RegClass); } return false; @@ -2484,9 +2488,13 @@ bool X86FastISel::X86SelectFPExt(const Instruction *I) { bool X86FastISel::X86SelectFPTrunc(const Instruction *I) { if (X86ScalarSSEf64 && I->getType()->isFloatTy() && I->getOperand(0)->getType()->isDoubleTy()) { + bool HasAVX512 = Subtarget->hasAVX512(); // fptrunc from double to float. - unsigned Opc = Subtarget->hasAVX() ? X86::VCVTSD2SSrr : X86::CVTSD2SSrr; - return X86SelectFPExtOrFPTrunc(I, Opc, &X86::FR32RegClass); + unsigned Opc = + HasAVX512 ? X86::VCVTSD2SSZrr + : Subtarget->hasAVX() ? X86::VCVTSD2SSrr : X86::CVTSD2SSrr; + return X86SelectFPExtOrFPTrunc( + I, Opc, HasAVX512 ? &X86::FR32XRegClass : &X86::FR32RegClass); } return false; diff --git a/test/CodeGen/X86/fast-isel-fptrunc-fpext.ll b/test/CodeGen/X86/fast-isel-fptrunc-fpext.ll index 0614a0e40a4..1035c256790 100644 --- a/test/CodeGen/X86/fast-isel-fptrunc-fpext.ll +++ b/test/CodeGen/X86/fast-isel-fptrunc-fpext.ll @@ -1,6 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=ALL --check-prefix=SSE ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=ALL --check-prefix=AVX +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=ALL --check-prefix=AVX ; ; Verify that fast-isel doesn't select legacy SSE instructions on targets that ; feature AVX. -- 2.40.0