[llvm] [SLP][NFC]Extract values state/operands analysis into separate class (PR #138724)
    Han-Kuan Chen via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu May  8 20:54:01 PDT 2025
    
    
  
================
@@ -2896,11 +2885,17 @@ class BoUpSLP {
         // Since operand reordering is performed on groups of commutative
         // operations or alternating sequences (e.g., +, -), we can safely tell
         // the inverse operations by checking commutativity.
-        auto [SelectedOp, Ops] = convertTo(cast<Instruction>(VL[Lane]), S);
+        auto *I = dyn_cast<Instruction>(VL[Lane]);
+        if (!I && isa<PoisonValue>(VL[Lane])) {
----------------
HanKuanChen wrote:
I just feel it is weird because the following code is removed; however, it could have been kept.
```
        assert((isa<Instruction>(V) || isa<PoisonValue>(V)) &&
               "Expected instruction or poison value");
```
If we don't introduce any new concept, why do we remove the assert?
And if we keep the original assert, we can use
```
        if (isa<PoisonValue>(VL[Lane])) {
          for (unsigned OpIdx : seq<unsigned>(NumOperands))
            OpsVec[OpIdx][Lane] = {Operands[OpIdx][Lane], true, false};
          continue;
        }
        auto [SelectedOp, Ops] = convertTo(cast<Instruction>(VL[Lane]), S);
```
https://github.com/llvm/llvm-project/pull/138724
    
    
More information about the llvm-commits
mailing list