[llvm] [InstCombine] Match scalable splats in m_ImmConstant (PR #132522)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 2 07:23:10 PDT 2025


================
@@ -858,18 +858,51 @@ inline bind_ty<const BasicBlock> m_BasicBlock(const BasicBlock *&V) {
   return V;
 }
 
+// TODO: Remove once UseConstant{Int,FP}ForScalableSplat is enabled by default,
+// and use m_Unless(m_ConstantExpr).
+struct immconstant_ty {
+  template <typename ITy> static bool isImmConstant(ITy *V) {
+    if (auto *CV = dyn_cast<Constant>(V)) {
+      if (!isa<ConstantExpr>(CV) && !CV->containsConstantExpression())
+        return true;
+
+      if (CV->getType()->isVectorTy()) {
+        if (auto *Splat = CV->getSplatValue(/* AllowPoison */ true)) {
----------------
dtcxzyw wrote:

```suggestion
        if (auto *Splat = CV->getSplatValue(/*AllowPoison=*/true)) {
```

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


More information about the llvm-commits mailing list