[AMDGPU] Improve abs modifier usage
authorThomas Symalla <github@thomassymalla.de>
Mon, 8 May 2023 18:50:20 +0000 (20:50 +0200)
committerThomas Symalla <thomas.symalla@amd.com>
Fri, 19 May 2023 10:02:21 +0000 (12:02 +0200)
commit91a7aa4c9b29fa217f45badeaa87c4667a28f807
tree26a430888df862993ebc77d0c29cbfa652baf30a
parentc10138a54f7f50c7a4d92b79a8887c51c52e2c20
[AMDGPU] Improve abs modifier usage

If a call to the llvm.fabs intrinsic has users in another reachable
BB, SelectionDAG will not apply the abs modifier to these users and
instead generate a v_and ..., 0x7fffffff instruction.
For fneg instructions, the issue is similar.
This patch implements `AMDGPUIselLowering::shouldSinkOperands`,
which allows CodegenPrepare to call `tryToSinkFreeOperands`.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D150347
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
llvm/test/CodeGen/AMDGPU/andorbitset.ll
llvm/test/CodeGen/AMDGPU/bug-sdag-emitcopyfromreg.ll
llvm/test/CodeGen/AMDGPU/fold-fabs.ll