[llvm] [VPlan] Only skip expansion for SCEVUnknown if it isn't an instruction. (PR #125235)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 07:43:19 PST 2025


================
@@ -1451,7 +1451,7 @@ Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty) {
   // Expand the code for this SCEV.
   Value *V = expand(SH);
 
-  if (Ty) {
+  if (Ty && Ty != V->getType()) {
     assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) &&
----------------
david-arm wrote:

This is just a thought, but the assert also looks a bit odd here. Shouldn't it be

```
   assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(V->getType()) &&
```

since we're casting between V->getType() and Ty? Is there something that guarantees SH->getType() == V->getType()?

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


More information about the llvm-commits mailing list