Skip to content

Commit 7091dd2

Browse files
authored
[AMDGPU] Fix lowering of abs for i16 vectors with more than 2 elements (#95413)
fixes #94606 Expansion of `ABS` for `i16` vectors with more than 2 elements is currently falling back to scalarization of the vector. This PR adds a custom lowering for `ABS` on `i16` vectors that splits the vector into multiple `<2 x i 16>` vectors.
1 parent 2146d12 commit 7091dd2

File tree

2 files changed

+1524
-2
lines changed

2 files changed

+1524
-2
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,8 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
791791
for (MVT VT : {MVT::v4i16, MVT::v8i16, MVT::v16i16, MVT::v32i16})
792792
// Split vector operations.
793793
setOperationAction({ISD::SHL, ISD::SRA, ISD::SRL, ISD::ADD, ISD::SUB,
794-
ISD::MUL, ISD::SMIN, ISD::SMAX, ISD::UMIN, ISD::UMAX,
795-
ISD::UADDSAT, ISD::SADDSAT, ISD::USUBSAT,
794+
ISD::MUL, ISD::ABS, ISD::SMIN, ISD::SMAX, ISD::UMIN,
795+
ISD::UMAX, ISD::UADDSAT, ISD::SADDSAT, ISD::USUBSAT,
796796
ISD::SSUBSAT},
797797
VT, Custom);
798798

@@ -5804,6 +5804,7 @@ SDValue SITargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
58045804
return lowerTRAP(Op, DAG);
58055805
case ISD::DEBUGTRAP:
58065806
return lowerDEBUGTRAP(Op, DAG);
5807+
case ISD::ABS:
58075808
case ISD::FABS:
58085809
case ISD::FNEG:
58095810
case ISD::FCANONICALIZE:

0 commit comments

Comments
 (0)