diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.cpp index 5d21aab513dd..e3b4a2dc048a 100644 --- a/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.cpp +++ b/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.cpp @@ -59,7 +59,6 @@ CSKYTargetLowering::CSKYTargetLowering(const TargetMachine &TM, setOperationAction(ISD::UREM, MVT::i32, Expand); setOperationAction(ISD::UDIVREM, MVT::i32, Expand); setOperationAction(ISD::SDIVREM, MVT::i32, Expand); - setOperationAction(ISD::CTTZ, MVT::i32, Expand); setOperationAction(ISD::CTPOP, MVT::i32, Expand); setOperationAction(ISD::ROTR, MVT::i32, Expand); setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand); @@ -103,6 +102,7 @@ CSKYTargetLowering::CSKYTargetLowering(const TargetMachine &TM, if (!Subtarget.has2E3()) { setOperationAction(ISD::ABS, MVT::i32, Expand); setOperationAction(ISD::BITREVERSE, MVT::i32, Expand); + setOperationAction(ISD::CTTZ, MVT::i32, Expand); setOperationAction(ISD::SDIV, MVT::i32, Expand); setOperationAction(ISD::UDIV, MVT::i32, Expand); } @@ -1397,7 +1397,22 @@ bool CSKYTargetLowering::decomposeMulByConstant(LLVMContext &Context, EVT VT, // unchanged on sub targets with MULT32, since not sure it is better. if (!Subtarget.hasE2() && (-1 - Imm).isPowerOf2()) return true; + // Break (MULT x, imm) to ([IXH32|IXW32|IXD32] (LSLI32 x, i0), x) when + // imm=(1<<i0)+[2|4|8] and imm has to be composed via a MOVIH32/ORI32 pair. + if (Imm.ugt(0xffff) && ((Imm - 2).isPowerOf2() || (Imm - 4).isPowerOf2()) && + Subtarget.hasE2()) + return true; + if (Imm.ugt(0xffff) && (Imm - 8).isPowerOf2() && Subtarget.has2E3()) + return true; } return false; } + +bool CSKYTargetLowering::isCheapToSpeculateCttz(Type *Ty) const { + return Subtarget.has2E3(); +} + +bool CSKYTargetLowering::isCheapToSpeculateCtlz(Type *Ty) const { + return Subtarget.hasE2(); +} |
