<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/80416>80416</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LoopVectorizer] Scalable predication trying to be scalarized
</td>
</tr>
<tr>
<th>Labels</th>
<td>
vectorization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davemgreen
</td>
</tr>
</table>
<pre>
This is a perhaps over-reduced example that fails with an error:
opt: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.cpp:708: virtual void llvm::VPRegionBlock::execute(llvm::VPTransformState*): Assertion `!State->VF.isScalable() && "VF is assumed to be non scalable."' failed.
https://godbolt.org/z/vdjWqGafr
```
define linkonce_odr dso_local void @_ZNK1MILi3EdEmlIdEES0_RKT_(ptr noalias align 8 %agg.result, ptr noundef nonnull align 8 dereferenceable(40) %this, ptr noundef nonnull align 8 dereferenceable(8) %a) local_unnamed_addr #0 align 2 {
entry:
%arrayidx.i.le.i = getelementptr inbounds i8, ptr %this, i64 32
%0 = load i64, ptr %arrayidx.i.le.i, align 8
%cmp12 = icmp sgt i64 %0, 0
br i1 %cmp12, label %for.body.lr.ph, label %for.cond.cleanup
for.body.lr.ph: ; preds = %entry
%arrayidx.i18.233.i = getelementptr inbounds i8, ptr %agg.result, i64 32
%1 = load i64, ptr %arrayidx.i18.233.i, align 8
%arrayidx.i18.131.i = getelementptr inbounds i8, ptr %agg.result, i64 24
%2 = load i64, ptr %arrayidx.i18.131.i, align 8
%arrayidx.i18.i = getelementptr inbounds i8, ptr %agg.result, i64 16
%3 = load i64, ptr %arrayidx.i18.i, align 8
%mul.1.i = mul i64 %2, %1
%mul.2.i = mul i64 %mul.1.i, %3
br label %for.body
for.cond.cleanup.loopexit: ; preds = %for.body
br label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
ret void
for.body: ; preds = %for.body.lr.ph, %for.body
%f.013 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
%div.i = udiv i64 %f.013, %mul.2.i
%rem.i = urem i64 %f.013, %mul.2.i
%div.1.i = udiv i64 %rem.i, %mul.1.i
%rem.1.i = urem i64 %rem.i, %mul.1.i
%div.2.i = udiv i64 %rem.1.i, %1
%rem.2.i = urem i64 %rem.1.i, %1
%mul.i = mul i64 %3, %div.i
%add.i = add i64 %mul.i, %div.1.i
%mul.1.i9 = mul i64 %add.i, %2
%add.1.i = add i64 %mul.1.i9, %div.2.i
%mul.2.i11 = mul i64 %add.1.i, %1
%add.2.i = add i64 %mul.2.i11, %rem.2.i
%sext.i = shl i64 %add.2.i, 32
%conv6.i = ashr exact i64 %sext.i, 32
%arrayidx.i.i.i = getelementptr inbounds i32, ptr null, i64 %conv6.i
store i32 poison, ptr %arrayidx.i.i.i, align 4
%inc = add nuw nsw i64 %f.013, 1
%exitcond.not = icmp eq i64 %inc, %0
br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body
}
```
Under LLVM-17 it looks like it will attempt to scalarize the predicated block, only generating the first block of the SVE vector.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykV1Fv2zgM_jXKi1BDluMkfchDujSHYd1hWHc94F4C2WJirbLkSXLa7tcfJNuJ47jthhVFEpv8-JEUJZHMWrFXAEuU3qB0PWG1K7RZcnaAcm8A1CTT_GX5rRAWC4sZrsAUrLJYH8BcGeB1DhzDMysrCdgVzOEdE9LiJ-EKzBQGY7RByQqRNSIrXTmUrDCiG6O1Q3Qj5aG8qoz-Dnn36L9Ehujmm2HK7rQpLaKbB8idNuIn-N9fJFNRXlUoWc3Jwls8CONqJvFBC46DlWSFktXDl6-wF1rdSJ0_Nq_gGfLaAaKLvtqR694xL1wheu3trqwF44RWGM0IonEQX6Hk9mETCXufM8ky6Y0heo0RnSE6w4jSh03IlrV1CRw7jTPASitsW0CEKEV0HnIFPGqS03wWzlXWu0U3iG72mmdaukibPaKbn4huDvz7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