Issue 75708
Summary [SystemZ] Problem with i128 induction variable
Labels new issue
Assignees uweigand
Reporter JonPsson1
    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.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to