[llvm] Count CallInst Arguments Attributes to reduce unnecessary extension (PR #73501)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 00:09:10 PST 2023
================
@@ -64,11 +64,19 @@ 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())) {
+ const AttributeList &PAL = CallI->getAttributes();
+ AttributeSet Attrs = PAL.getParamAttrs(U.getOperandNo());
----------------
zengdage wrote:
Yeah, I think need to make sure the use is one of the call operands. So I want to add `if (!CallI->isArgOperand(&U)) continue;` between line 72 and line 73. Do you think that's okay?
https://github.com/llvm/llvm-project/pull/73501
More information about the llvm-commits
mailing list