[llvm] [VPlan] Expand SCEV casts in VPSCEVExpander. (PR #206371)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 05:21:59 PDT 2026


================
@@ -886,6 +878,29 @@ VPValue *VPSCEVExpander::tryToExpand(const SCEV *S) {
                                 VPIRFlags::getDefaultFlags(Instruction::UDiv),
                                 DL);
   }
+  case scTruncate:
+  case scZeroExtend:
+  case scSignExtend: {
+    auto *Cast = cast<SCEVCastExpr>(S);
+    VPValue *Op = tryToExpand(Cast->getOperand());
+    if (!Op)
+      return nullptr;
+    Instruction::CastOps Opcode;
+    switch (S->getSCEVType()) {
+    case scTruncate:
+      Opcode = Instruction::Trunc;
+      break;
+    case scZeroExtend:
+      Opcode = Instruction::ZExt;
+      break;
+    case scSignExtend:
+      Opcode = Instruction::SExt;
+      break;
+    default:
+      llvm_unreachable("not a cast SCEV");
----------------
artagnon wrote:

```suggestion
      llvm_unreachable("Unhandled cast SCEV");
```

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


More information about the llvm-commits mailing list