From: Craig Topper Date: Thu, 12 Jul 2018 18:03:56 +0000 (+0000) Subject: [X86][FastISel] Choose EVEX instructions when possible when lowering x86_sse_cvttss2s... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d43f58231cd3a75b5df540aac75b44e8654ce209;p=platform%2Fupstream%2Fllvm.git [X86][FastISel] Choose EVEX instructions when possible when lowering x86_sse_cvttss2si and similar intrinsics. This should fix a machine verifier error. llvm-svn: 336924 --- diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index b37b283..4199eb2 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -2996,18 +2996,22 @@ bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) { if (!isTypeLegal(RetTy, VT)) return false; - static const uint16_t CvtOpc[2][2][2] = { - { { X86::CVTTSS2SIrr, X86::VCVTTSS2SIrr }, - { X86::CVTTSS2SI64rr, X86::VCVTTSS2SI64rr } }, - { { X86::CVTTSD2SIrr, X86::VCVTTSD2SIrr }, - { X86::CVTTSD2SI64rr, X86::VCVTTSD2SI64rr } } + static const uint16_t CvtOpc[3][2][2] = { + { { X86::CVTTSS2SIrr, X86::CVTTSS2SI64rr }, + { X86::CVTTSD2SIrr, X86::CVTTSD2SI64rr } }, + { { X86::VCVTTSS2SIrr, X86::VCVTTSS2SI64rr }, + { X86::VCVTTSD2SIrr, X86::VCVTTSD2SI64rr } }, + { { X86::VCVTTSS2SIZrr, X86::VCVTTSS2SI64Zrr }, + { X86::VCVTTSD2SIZrr, X86::VCVTTSD2SI64Zrr } }, }; - bool HasAVX = Subtarget->hasAVX(); + unsigned AVXLevel = Subtarget->hasAVX512() ? 2 : + Subtarget->hasAVX() ? 1 : + 0; unsigned Opc; switch (VT.SimpleTy) { default: llvm_unreachable("Unexpected result type."); - case MVT::i32: Opc = CvtOpc[IsInputDouble][0][HasAVX]; break; - case MVT::i64: Opc = CvtOpc[IsInputDouble][1][HasAVX]; break; + case MVT::i32: Opc = CvtOpc[AVXLevel][IsInputDouble][0]; break; + case MVT::i64: Opc = CvtOpc[AVXLevel][IsInputDouble][1]; break; } // Check if we can fold insertelement instructions into the convert.