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

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 19:41:54 PST 2023


================
@@ -69,6 +69,20 @@ static ISD::NodeType getPreferredExtendForValue(const Instruction *I) {
       NumOfSigned += CI->isSigned();
       NumOfUnsigned += CI->isUnsigned();
     }
+    if (const auto *CallI = dyn_cast<CallInst>(U)) {
+      for (unsigned op = 0, Eop = CallI->arg_size(); op < Eop; ++op) {
+        if (CallI->getArgOperand(op) == I) {
+          const AttributeList &PAL = CallI->getAttributes();
+          AttributeSet Attrs = PAL.getParamAttrs(op);
+          if (Attrs.hasAttributes()) {
+            for (const auto &Attr : Attrs) {
----------------
zengdage wrote:

I have updated it. Call the `Attrs.hasAttribute()` directly.

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


More information about the llvm-commits mailing list