[llvm] [ConstantFolding] Add folding for [de]interleave2, insert and extract (PR #141301)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 07:39:41 PDT 2025


================
@@ -3734,6 +3738,98 @@ static Constant *ConstantFoldFixedVectorCall(
     }
     return nullptr;
   }
+  case Intrinsic::vector_extract: {
+    auto *Vec = dyn_cast<Constant>(Operands[0]);
+    auto *Idx = cast<ConstantInt>(Operands[1]);
+    if (!Vec || !Idx || !isa<FixedVectorType>(Vec->getType()))
----------------
lukel97 wrote:

```suggestion
    unsigned Idx = cast<ConstantInt>(Operands[1])->getZExtValue();
    if (!Vec || !isa<FixedVectorType>(Vec->getType()))
```

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


More information about the llvm-commits mailing list