AMDGPU/GlobalISel: Fix constant bus restriction errors for med3
authorPetar Avramovic <Petar.Avramovic@amd.com>
Wed, 1 Dec 2021 16:39:39 +0000 (17:39 +0100)
committerPetar Avramovic <Petar.Avramovic@amd.com>
Wed, 1 Dec 2021 20:36:37 +0000 (21:36 +0100)
commit641906da8de2f131a433ec26d7fd44ee74abfa5b
tree371ac5586a2f09eeb553050f1c5bfb708407da69
parent66071f440c31b95cb2514a8daa003b62882b8245
AMDGPU/GlobalISel: Fix constant bus restriction errors for med3

Detected on targets older then gfx10 (e.g. gfx9) for constants that are
too large to be inlined (constant are sgpr by default).
In med3 combine it is expected that regbankselect maps all operands of
min/max we try to match to vgpr. However constants are mapped to sgpr
and there will be a sgpr-to-vgpr copy. Matchers look through sgpr-to-vgpr
copies and return sgpr and these break constant bus restriction.
Build med3 with all vgpr operands. Use existing sgpr-to-vgpr copies for
matched sgprs. If there is no such copy (not expected) build one.

Differential Revision: https://reviews.llvm.org/D114700
llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-smed3.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-umed3.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/smed3.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/umed3.ll