[llvm] Count CallInst Arguments Attributes to reduce unnecessary extension (PR #73501)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 20:09:41 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());
----------------
topperc wrote:

Do we need to make sure the use is one of the call operands and not the callee of an indirect call? Not sure how we determine what Instructions `getPreferredExtendForValue` is called for.

https://github.com/llvm/llvm-project/pull/73501


More information about the llvm-commits mailing list