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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed May 28 09:45:43 PDT 2025


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

I believe the index has to be a constant so you might as well just cast it
```suggestion
    auto *Idx = cast<ConstantInt>(Operands[1]);
```

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


More information about the llvm-commits mailing list