<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/75708>75708</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SystemZ] Problem with i128 induction variable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
uweigand
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JonPsson1
</td>
</tr>
</table>
<pre>
Reduced test case:
```
__int128 a;
char *b;
void c() {
for (;; a++)
if (b[a])
break;
}
```
cat tc.ll
```
@b = dso_local local_unnamed_addr global ptr null, align 8
@a = dso_local local_unnamed_addr global i128 0, align 8
define dso_local void @c() local_unnamed_addr {
entry:
%0 = load ptr, ptr @b, align 8
%a.promoted = load i128, ptr @a, align 8
%idxprom2 = trunc i128 %a.promoted to i64
%arrayidx3 = getelementptr inbounds i8, ptr %0, i64 %idxprom2
%1 = load i8, ptr %arrayidx3, align 1
%tobool.not4 = icmp eq i8 %1, 0
br i1 %tobool.not4, label %for.inc, label %for.end
for.inc:
%inc15 = phi i128 [ %inc, %for.inc ], [ %a.promoted, %entry ]
%inc = add nsw i128 %inc15, 1
store i128 %inc, ptr @a, align 8
%idxprom = trunc i128 %inc to i64
%arrayidx = getelementptr inbounds i8, ptr %0, i64 %idxprom
%2 = load i8, ptr %arrayidx, align 1
%tobool.not = icmp eq i8 %2, 0
br i1 %tobool.not, label %for.inc, label %for.end
for.end: ; preds = %for.inc, %entry
ret void
}
```
```
llc -mcpu=z13 tc.ll -o -
Impossible reg-to-reg copy
UNREACHABLE executed at /home/ijonpan/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp:863!
```
`renamable $r3d = COPY killed renamable $v0`
It looks like the i128 induction variable is truncated to i64, which is selected as '%11:addr64bit = COPY %2:vr128bit', which then results later in the above COPY.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVk1v4zYQ_TX0ZWBDoiRbOfhgx2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