[NFC][AMDGPU] coverity fixes (#21306)
cherry - pick of
https://github.com/llvm/llvm-project/commit/65cdee827b76f137986549b69a59e9da74c0e702
this PR additionally contains fixes for potential "logically dead code"
issues found by Coverity: 3498206, 3498210, 3496793
Co-authored-by: Mirko BrkuĊĦanin <Mirko.Brkusanin@amd.com>