Issue 242595
Summary [AMDGPU] Debug uses change i1 lane-mask lowering
Labels new issue
Assignees
Reporter yqtian-se
    Compiling this kernel with `-g` changes how lane masks are initialized and
allocated. In particular, one mask is initialized from `exec_lo` instead of
`-1`.

```opencl
__kernel void phi(__global int *out, __global int *in, int n) {
  int i = 0;
  int tid = get_local_id(0);
  bool value = true;
  bool previous;
  do {
 previous = value;
    if (value)
      value = in[i + tid] == 0;
 i++;
  } while (i != n);
  bool last = previous;
  out[tid] = value;
}
```

```sh
clang --target=amdgcn-amd-amdhsa -mcpu=gfx1010 -x cl -cl-std=CL2.0 \
  -nogpulib -ffreestanding -O1 -g -S input.cl -o with-g.s
clang --target=amdgcn-amd-amdhsa -mcpu=gfx1010 -x cl -cl-std=CL2.0 \
  -nogpulib -ffreestanding -O1 -g0 -S input.cl -o without-g.s
diff -u without-g.s with-g.s
```

The relevant difference is:

```diff
-	s_mov_b32 s5, -1
+	s_mov_b32 s5, exec_lo
```

The first difference appears in `si-i1-copies`. `mergeIncomingLaneMasks`
collects blocks from `use_instructions(DstReg)`, including blocks containing
only debug uses. A `DBG_VALUE` outside the loop therefore changes the computed
post-dominator bound and selects different lane-mask lowering.

Debug-only uses should not change this decision. This was reproduced with
clang `7517bcdb0b87`; the responsible code remains unchanged on LLVM main
`2451a1eadfa1`.

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

Reply via email to