15 Commits

Author SHA1 Message Date
Yashwant Singh
3dc413e25d [AMDGPU] Skip debug instruction uses while optimizing live range of a reg in SIOptimizeVGPRLiveRange
This will prevent the `assert(!O.readsReg())` from firing in
SIOptimizeVGPRLiveRange::optimizeLiveRange

Fix for #64163

Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D156893
2023-08-07 11:35:39 +05:30
Jay Foad
3030c03988 [AMDGPU] Make use of MachineInstr::all_defs and all_uses. NFCI. 2023-06-05 10:32:33 +01:00
Nicolai Hähnle
1e63f8272e AMDGPU: Fix an assertion in SIOptimizeVGPRLiveRange
As the comment notes, the shader results in an INSERT_SUBREG with
"undef" (dead) operand in the Endif block. The same can happen with
REG_SEQUENCE. The register is considered dead from a liveness
analysis perspective. The correct thing to do seems to be nothing:
we keep the undef use of the register, the register allocator should
still be able to take the liveness into account correctly.

Differential Revision: https://reviews.llvm.org/D149161
2023-04-27 09:39:44 +02:00
Jay Foad
5073ae2a88 [AMDGPU] Fix duplicated words in comments 2022-11-03 15:33:30 +00:00
Ruiling Song
4dcb42fae5 AMDGPU: Skip unexpected CFG in SIOptimizeVGPRLiveRange
There are some cases that we use si_if/si_else in unatural way.
Just skip them.

Fixes: https://github.com/llvm/llvm-project/issues/55922

Reviewed by: critson

Differential Revision: https://reviews.llvm.org/D128193
2022-06-22 12:49:41 +08:00
Carl Ritson
2bca7d859a [AMDGPU] Graceful abort for waterfalls in SIOptimizeVGPRLiveRange
If the CFG structure of a waterfall loop is not the expected shape
then gracefully abort traversing the IR for the given loop.
This applies to nest waterfall loops which are not supported by
the VGPR live range optimizer.

Reviewed By: ruiling

Differential Revision: https://reviews.llvm.org/D123480
2022-04-12 14:15:44 +09:00
Carl Ritson
1f52d02ceb [AMDGPU] Split waterfall loop exec manipulation
Split waterfall loops into multiple blocks so that exec mask
manipulation (s_and_saveexec) does not occur in the middle of
a block.

VGPR live range optimizer is updated to handle waterfall loops
spanning multiple blocks.

Reviewed By: ruiling

Differential Revision: https://reviews.llvm.org/D122200
2022-03-28 17:44:54 +09:00
Matt Arsenault
e09f98a69a AMDGPU: Fix LiveVariables error after optimizing VGPR ranges
This was not removing the block from the live set depending on the
specific depth first visit order. Fixes a verifier error in the OpenCL
conformance tests.
2022-01-17 09:38:35 -05:00
Matt Arsenault
4fc18de335 AMDGPU: Clear NoPHIs property in SIOptimizeVGPRLiveRanges
Fixes verifier error when writing MIR tests that didn't have phis to
begin with.
2022-01-06 11:01:51 -05:00
Neubauer, Sebastian
d1f45ed58f [AMDGPU][NFC] Fix typos
Differential Revision: https://reviews.llvm.org/D113672
2021-11-12 11:37:21 +01:00
Sebastian Neubauer
b642d01fa8 [AMDGPU] Improve killed check for vgpr optimization
The killed flag is not always set. E.g. when a variable is used in a
loop, it is never marked as killed, although it is unused in following
basic blocks. Also, we try to deprecate kill flags and not use them.

Check if the register is live in the endif block. If not, consider it
killed in the then and else blocks.

The vgpr-liverange tests have two new tests with loops
(pre-committed, so the diff is visible).
I also needed to change the subtarget to gfx10.1, otherwise calls
are not working.

Differential Revision: https://reviews.llvm.org/D106291
2021-07-21 15:24:59 +02:00
Sebastian Neubauer
ad2c66ec5d [AMDGPU] Optimize VGPR LiveRange in waterfall loops
The loops are run exactly once per lane, so VGPRs do not need to be
saved. Use the SIOptimizeVGPRLiveRange pass to add phi nodes that take
undef when coming from the loop.

There is still a shortcoming:
Return values from a function call in the loop are copied because their
live range conflicts with the live range of arguments, even if arguments
are only IMPLICIT_DEF after the phi insertion.

Differential Revision: https://reviews.llvm.org/D105192
2021-07-13 12:15:08 +02:00
Sebastian Neubauer
9ced1e44ad [AMDGPU] Fix typo 2021-07-08 10:07:33 +02:00
Jordan Rupprecht
b650778dc4 [NFC] Wrap entire assert-only block in LLVM_DEBUG 2021-06-21 04:01:27 -07:00
Ruiling Song
208332de8a [AMDGPU] Add Optimize VGPR LiveRange Pass.
This pass aims to optimize VGPR live-range in a typical divergent if-else
control flow. For example:

def(a)
if(cond)
  use(a)
  ... // A
else
  use(a)

As AMDGPU access vgpr with respect to active-mask, we can mark `a` as
dead in region A. For details, please refer to the comments in
implementation file.

The pass is enabled by default, the frontend can disable it through
"-amdgpu-opt-vgpr-liverange=false".

Differential Revision: https://reviews.llvm.org/D102212
2021-06-21 15:25:55 +08:00