diff options
author | ZengZhijin <977862353@qq.com> | 2023-12-05 16:55:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 09:55:52 +0100 |
commit | eaba81fd245da952a2a708495bf97d7791e8b965 (patch) | |
tree | 8c1847577698f27bf36bd17d5032eaac4688ade1 /llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | |
parent | 43455a2f0d3cdcd8dc46c4fbdebf4e655b26c2f2 (diff) | |
download | llvm-eaba81fd245da952a2a708495bf97d7791e8b965.zip llvm-eaba81fd245da952a2a708495bf97d7791e8b965.tar.gz llvm-eaba81fd245da952a2a708495bf97d7791e8b965.tar.bz2 |
[SDAG] Count call argument attributes to reduce unnecessary extension (#73501)
Count how often the value is with signext/zeroext calls
when determining the preferred extension type.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 1d0a03c..1128ecf 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -64,11 +64,18 @@ static ISD::NodeType getPreferredExtendForValue(const Instruction *I) { // can be exposed. ISD::NodeType ExtendKind = ISD::ANY_EXTEND; unsigned NumOfSigned = 0, NumOfUnsigned = 0; - for (const User *U : I->users()) { - if (const auto *CI = dyn_cast<CmpInst>(U)) { + for (const Use &U : I->uses()) { + if (const auto *CI = dyn_cast<CmpInst>(U.getUser())) { NumOfSigned += CI->isSigned(); NumOfUnsigned += CI->isUnsigned(); } + if (const auto *CallI = dyn_cast<CallBase>(U.getUser())) { + if (!CallI->isArgOperand(&U)) + continue; + unsigned ArgNo = CallI->getArgOperandNo(&U); + NumOfUnsigned += CallI->paramHasAttr(ArgNo, Attribute::ZExt); + NumOfSigned += CallI->paramHasAttr(ArgNo, Attribute::SExt); + } } if (NumOfSigned > NumOfUnsigned) ExtendKind = ISD::SIGN_EXTEND; |