Fix SGPR + offset Scratch offset folding
authorPetar Avramovic <Petar.Avramovic@amd.com>
Wed, 8 Mar 2023 15:18:56 +0000 (16:18 +0100)
committerPetar Avramovic <Petar.Avramovic@amd.com>
Thu, 9 Mar 2023 09:52:44 +0000 (10:52 +0100)
commit5e56d5999914538c8060e4fd9b23ec19650eebce
tree5ce0e228512db6d450fbd56ffb42d03321bb47ae
parentb2c48559c882fd558f91e471c4d23ea7b0c6e718
Fix SGPR + offset Scratch offset folding

Values in SGPR register are treated as unsigned by hardware.

When value in 32-bit SGPR base can be negative calculate offset using
32-bit add instruction, otherwise use sgpr base(unsigned) + offset.
Does not affect case where whole offset comes from SGPR register
(immediate offset is 0).

LoopStrengthReduce.cpp changes offsets to negative and in some
iterations value in SGPR register could be negative.

Differential Revision: https://reviews.llvm.org/D144955
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
llvm/test/CodeGen/AMDGPU/GlobalISel/call-outgoing-stack-args.ll
llvm/test/CodeGen/AMDGPU/flat-scratch-i8-i16.ll
llvm/test/CodeGen/AMDGPU/gfx-callable-argument-types.ll
llvm/test/CodeGen/AMDGPU/gfx-callable-return-types.ll