diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -1652,10 +1652,6 @@ virtual bool isJumpTableRelative() const; - /// Return true if a mulh[s|u] node for a specific type is cheaper than - /// a multiply followed by a shift. This is false by default. - virtual bool isMulhCheaperThanMulShift(EVT Type) const { return false; } - /// If a physical register, this specifies the register that /// llvm.savestack/llvm.restorestack should save and restore. unsigned getStackPointerRegisterToSaveRestore() const { diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4118,7 +4118,7 @@ // If the type twice as wide is legal, transform the mulhs to a wider multiply // plus a shift. - if (!TLI.isMulhCheaperThanMulShift(VT) && VT.isSimple() && !VT.isVector()) { + if (!TLI.isOperationLegal(ISD::MULHS, VT) && VT.isSimple() && !VT.isVector()) { MVT Simple = VT.getSimpleVT(); unsigned SimpleSize = Simple.getSizeInBits(); EVT NewVT = EVT::getIntegerVT(*DAG.getContext(), SimpleSize*2); @@ -4174,7 +4174,7 @@ // If the type twice as wide is legal, transform the mulhu to a wider multiply // plus a shift. - if (!TLI.isMulhCheaperThanMulShift(VT) && VT.isSimple() && !VT.isVector()) { + if (!TLI.isOperationLegal(ISD::MULHU, VT) && VT.isSimple() && !VT.isVector()) { MVT Simple = VT.getSimpleVT(); unsigned SimpleSize = Simple.getSizeInBits(); EVT NewVT = EVT::getIntegerVT(*DAG.getContext(), SimpleSize*2); diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -354,6 +354,10 @@ setOperationAction(ISD::ROTR, VT, Expand); } + // AArch64 doesn't have i32 MULH{S|U}. + setOperationAction(ISD::MULHU, MVT::i32, Expand); + setOperationAction(ISD::MULHS, MVT::i32, Expand); + // AArch64 doesn't have {U|S}MUL_LOHI. setOperationAction(ISD::UMUL_LOHI, MVT::i64, Expand); setOperationAction(ISD::SMUL_LOHI, MVT::i64, Expand); diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.h b/llvm/lib/Target/PowerPC/PPCISelLowering.h --- a/llvm/lib/Target/PowerPC/PPCISelLowering.h +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.h @@ -950,11 +950,6 @@ Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override; - /// isMulhCheaperThanMulShift - Return true if a mulh[s|u] node for a - /// specific type is cheaper than a multiply followed by a shift. - /// This is true for words and doublewords on 64-bit PowerPC. - bool isMulhCheaperThanMulShift(EVT Type) const override; - /// Override to support customized stack guard loading. bool useLoadStackGuardNode() const override; void insertSSPDeclarations(Module &M) const override; diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -1401,16 +1401,6 @@ return VT.isScalarInteger(); } -/// isMulhCheaperThanMulShift - Return true if a mulh[s|u] node for a specific -/// type is cheaper than a multiply followed by a shift. -/// This is true for words and doublewords on 64-bit PowerPC. -bool PPCTargetLowering::isMulhCheaperThanMulShift(EVT Type) const { - if (Subtarget.isPPC64() && (isOperationLegal(ISD::MULHS, Type) || - isOperationLegal(ISD::MULHU, Type))) - return true; - return TargetLowering::isMulhCheaperThanMulShift(Type); -} - const char *PPCTargetLowering::getTargetNodeName(unsigned Opcode) const { switch ((PPCISD::NodeType)Opcode) { case PPCISD::FIRST_NUMBER: break;