diff options
author | Henry Jiang <h243jian@uwaterloo.ca> | 2025-02-24 17:53:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 17:53:43 -0500 |
commit | 6d0cfbc9c0e25f9e652f5f8b3bca2d7a0768619e (patch) | |
tree | 4dd7bcf4f7c338a2d12b66ef864c17289328fd92 /llvm/lib | |
parent | 911e94c6516926b462bc6d1d4a77dcc701b7e3db (diff) | |
download | llvm-6d0cfbc9c0e25f9e652f5f8b3bca2d7a0768619e.zip llvm-6d0cfbc9c0e25f9e652f5f8b3bca2d7a0768619e.tar.gz llvm-6d0cfbc9c0e25f9e652f5f8b3bca2d7a0768619e.tar.bz2 |
[PPC] Implement `areInlineCompatible` (#126562)
After the default implementation swap from
https://github.com/llvm/llvm-project/pull/117493, where
`areInlineCompatible` checks if the callee features are a subset of
caller features. This is not a safe assumption in general on PPC. We
fallback to check for strict feature set equality for now, and see what
improvements we can make.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp index c308ec3..26e9b4b 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp @@ -895,6 +895,20 @@ PPCTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, return BaseT::getIntrinsicInstrCost(ICA, CostKind); } +bool PPCTTIImpl::areInlineCompatible(const Function *Caller, + const Function *Callee) const { + const TargetMachine &TM = getTLI()->getTargetMachine(); + + const FeatureBitset &CallerBits = + TM.getSubtargetImpl(*Caller)->getFeatureBits(); + const FeatureBitset &CalleeBits = + TM.getSubtargetImpl(*Callee)->getFeatureBits(); + + // Check that targets features are exactly the same. We can revisit to see if + // we can improve this. + return CallerBits == CalleeBits; +} + bool PPCTTIImpl::areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef<Type *> &Types) const { diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h index 3cb60d7..bf3ddad 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h @@ -139,6 +139,8 @@ public: bool UseMaskForCond = false, bool UseMaskForGaps = false); InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind); + bool areInlineCompatible(const Function *Caller, + const Function *Callee) const; bool areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef<Type *> &Types) const; bool hasActiveVectorLength(unsigned Opcode, Type *DataType, |