From eee40f92a9094f77514a417a3c727fb24e19bf96 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 12 Feb 2014 10:17:54 +0000 Subject: [PATCH] R600: Always implement both versions of isTruncateFree and add a sanity check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201222 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/R600/AMDGPUISelLowering.cpp | 10 ++++++++-- lib/Target/R600/AMDGPUISelLowering.h | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/Target/R600/AMDGPUISelLowering.cpp b/lib/Target/R600/AMDGPUISelLowering.cpp index 1df02d3f987..c67ac1c11cf 100644 --- a/lib/Target/R600/AMDGPUISelLowering.cpp +++ b/lib/Target/R600/AMDGPUISelLowering.cpp @@ -232,9 +232,15 @@ bool AMDGPUTargetLowering::isFNegFree(EVT VT) const { return VT == MVT::f32; } -bool AMDGPUTargetLowering::isTruncateFree(EVT, EVT Dest) const { +bool AMDGPUTargetLowering::isTruncateFree(EVT Source, EVT Dest) const { // Truncate is just accessing a subregister. - return (Dest.getSizeInBits() % 32 == 0); + return Dest.bitsLT(Source) && (Dest.getSizeInBits() % 32 == 0); +} + +bool AMDGPUTargetLowering::isTruncateFree(Type *Source, Type *Dest) const { + // Truncate is just accessing a subregister. + return Dest->getPrimitiveSizeInBits() < Source->getPrimitiveSizeInBits() && + (Dest->getPrimitiveSizeInBits() % 32 == 0); } //===---------------------------------------------------------------------===// diff --git a/lib/Target/R600/AMDGPUISelLowering.h b/lib/Target/R600/AMDGPUISelLowering.h index 311959e682b..b53ba0a542f 100644 --- a/lib/Target/R600/AMDGPUISelLowering.h +++ b/lib/Target/R600/AMDGPUISelLowering.h @@ -79,10 +79,11 @@ protected: public: AMDGPUTargetLowering(TargetMachine &TM); - virtual bool isFAbsFree(EVT VT) const; - virtual bool isFNegFree(EVT VT) const; + virtual bool isFAbsFree(EVT VT) const LLVM_OVERRIDE; + virtual bool isFNegFree(EVT VT) const LLVM_OVERRIDE; virtual bool isTruncateFree(EVT Src, EVT Dest) const LLVM_OVERRIDE; - virtual MVT getVectorIdxTy() const; + virtual bool isTruncateFree(Type *Src, Type *Dest) const LLVM_OVERRIDE; + virtual MVT getVectorIdxTy() const LLVM_OVERRIDE; virtual bool isLoadBitCastBeneficial(EVT, EVT) const LLVM_OVERRIDE; virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, -- 2.34.1