[llvm] [Scalarizer] Fix to only scalarize if intrinsic was marked as isTriviallyScalarizable (PR #113625)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 25 01:40:00 PDT 2024


================
@@ -1084,6 +1084,17 @@ bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) {
   ValueVector Res;
   if (!isStructOfMatchingFixedVectors(OpTy))
     return false;
+  if (CallInst *CI = dyn_cast<CallInst>(Op)) {
+    Function *F = CI->getCalledFunction();
+    if (!F)
+      return false;
+    Intrinsic::ID ID = F->getIntrinsicID();
+    if (ID == Intrinsic::not_intrinsic || !isTriviallyScalarizable(ID))
+      return false;
+    // Note: Fall through means Operand is a`CallInst` and it is defined in
+    // `isTriviallyScalarizable`.
+  } else
+    return false;
----------------
jayfoad wrote:

Will you ever see non-intrinsic calls here? If so, please add a test case for that.

Also nit: the "else" clause should have braces if the "if" clause has braces.

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


More information about the llvm-commits mailing list