[llvm] [CodeGen] Lower vector interleaves of const splats to a wider splat (PR #151110)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 03:40:01 PDT 2025


================
@@ -12594,27 +12594,40 @@ void SelectionDAGBuilder::visitVectorDeinterleave(const CallInst &I,
   setValue(&I, Res);
 }
 
-void SelectionDAGBuilder::visitVectorInterleave(const CallInst &I,
+void SelectionDAGBuilder::visitVectorInterleave(const CallInst &CI,
                                                 unsigned Factor) {
   auto DL = getCurSDLoc();
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
-  EVT InVT = getValue(I.getOperand(0)).getValueType();
-  EVT OutVT = TLI.getValueType(DAG.getDataLayout(), I.getType());
+  EVT InVT = getValue(CI.getOperand(0)).getValueType();
+  EVT OutVT = TLI.getValueType(DAG.getDataLayout(), CI.getType());
 
   SmallVector<SDValue, 8> InVecs(Factor);
-  for (unsigned i = 0; i < Factor; ++i) {
-    InVecs[i] = getValue(I.getOperand(i));
-    assert(InVecs[i].getValueType() == InVecs[0].getValueType() &&
+  bool OperandsAreSame = true;
+  for (unsigned I = 0; I < Factor; ++I) {
+    InVecs[I] = getValue(CI.getOperand(I));
+    assert(InVecs[I].getValueType() == InVecs[0].getValueType() &&
            "Expected VTs to be the same");
+    if (InVecs[I] != InVecs[0])
+      OperandsAreSame = false;
+  }
+
+  if (OperandsAreSame) {
----------------
lukel97 wrote:

Does this also work?
```suggestion
  if (all_equal(InVecs)) {
```

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


More information about the llvm-commits mailing list