<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146990>146990</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR][SCF] pipelining pass use of uninitialized value
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Hyffer
</td>
</tr>
</table>
<pre>
Here in the code:
https://github.com/llvm/llvm-project/blob/61529d9e36fa86782a2458e6bdeedf7f376ef4b5/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp#L127
https://github.com/llvm/llvm-project/blob/61529d9e36fa86782a2458e6bdeedf7f376ef4b5/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp#L148-L153
`maxStage` is used before initialized.
When it checks `numIteration > maxStage` at line-127, maxStage is always 0 as default. So it will mistakenly decide if the loop trip count is actually greater than stage number, and thus pipelining a loop that should not have done.
---
At older llvm version(17), it was correct. The problem is introduced in this commit: https://github.com/llvm/llvm-project/commit/ef112833e11e94ea049f98bec4a29b4fe96a25dd
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUVE2L5DYQ_TXypehGluUPHXyY3UmzCxMImYWcy1a5rawsGX30pvPrg9yTzVznGDAY46r3XlW9KozRXB3RyNpPrH2uMKfVh_HLfVkoVJPX9_ELBQLjIK0Es9fEmifGy7OmtMfyJS5MXK4mrXk6z35j4mLt7d_XaQ_-T5oTE5fJ-omJS1e3QmlFTbfg0PWDQCHbgbpJE-mlX5q-o0VOLROXzZpQcEzJezZoH0Cvnwvjt4AuLj5skYnLi_f7b2Yna5xx1_O870w0L7Xo_z9a5XB6qdvmIZh1fMO_XhNeiXUcTIQcScNEiz_GYZJBa_4mfX7E_7GSA5NgXmn-HoF13OXta6KAyXgHrPkF3uNhAmscnUqDxOefvwoP2h94j8ABI2haMNt0hldfwH8Ya2EzMeF3cvYOmmajCcxymMN6v0MKZofZZ5cOrDlltPYO10CYKEBa0UE8qFzeJgqFHZ2GtOYI-8-mAL7BrZggrj5bDc4nWPFGoL2jt7JPpxPjT08JvNUUoAwRbhSi8Y6Joe6ZUIWhaMcIsw-B5nSGbyvBHvxkaSsyjUvB6zyTfhjdlNBtM4k1T_Bh67yligstdS2GpqG6JiUJuVSLGiaaJQo1yYVUh6LVutJjo1WjsKKx7tu6VV0vVbWOpHHhs5iEktPQajl3XKlB1ovu-kYJrMwouGh5zyUXjeLqPEjeac5lJ4dpGKRiktOGxp6LxrMP18rEmGmsZacUryxOZOOx_EI8DCzKGQjjUdOUr5FJbk1M8T-EZJI9DsavL19_Z-0zaz8Vk7fP7-e3YzwsC36B7N75FW5oM1U52PHDnT20lw16k38bxT8BAAD__6YIiI0">