[llvm] [AMDGPU] [DO NOT MERGE] Nonsuccessful Attempt At Using SelectionDAG Hooks for abs i8/i16 (PR #167064)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 21:03:39 PST 2025


================
@@ -177,6 +178,10 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
     addRegisterClass(MVT::v32i16, &AMDGPU::SGPR_512RegClass);
     addRegisterClass(MVT::v32f16, &AMDGPU::SGPR_512RegClass);
     addRegisterClass(MVT::v32bf16, &AMDGPU::SGPR_512RegClass);
+
+    // We don't want the default expansion of 16-bit ABS since we can
+    // sign-extend and use the 32-bit ABS operation for 16-bit ABS with SGPRs
+    setOperationAction(ISD::ABS, {MVT::i8,MVT::i16}, Custom);
----------------
arsenm wrote:

It will be easier to ignore i8 for now and just get i16 working. i8 adds way more problems if you're having trouble with the easy case 

https://github.com/llvm/llvm-project/pull/167064


More information about the llvm-commits mailing list