Skip to content

Commit 1893053

Browse files
committed
Make 32-bit ABS is legal DAG node
Signed-off-by: John Lu <[email protected]>
1 parent cfe6bec commit 1893053

File tree

10 files changed

+967
-1014
lines changed

10 files changed

+967
-1014
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ AMDGPUTargetLowering::AMDGPUTargetLowering(const TargetMachine &TM,
514514
MVT::i64, Custom);
515515
setOperationAction(ISD::SELECT_CC, MVT::i64, Expand);
516516

517-
setOperationAction({ISD::SMIN, ISD::UMIN, ISD::SMAX, ISD::UMAX}, MVT::i32,
518-
Legal);
517+
setOperationAction({ISD::ABS, ISD::SMIN, ISD::UMIN, ISD::SMAX, ISD::UMAX},
518+
MVT::i32, Legal);
519519

520520
setOperationAction(
521521
{ISD::CTTZ, ISD::CTTZ_ZERO_UNDEF, ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF},

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14945,6 +14945,13 @@ SDValue SITargetLowering::performMinMaxCombine(SDNode *N,
1494514945
}
1494614946
}
1494714947

14948+
// max(x, neg(x)) -> abs(x)
14949+
if (Opc == ISD::SMAX && VT == MVT::i32) {
14950+
SDValue Value;
14951+
if (sd_match(N, m_SMax(m_Value(Value), m_Neg(m_Deferred(Value)))))
14952+
return DAG.getNode(ISD::ABS, SDLoc(N), VT, Value);
14953+
}
14954+
1494814955
// min(max(x, K0), K1), K0 < K1 -> med3(x, K0, K1)
1494914956
// max(min(x, K0), K1), K1 < K0 -> med3(x, K1, K0)
1495014957
if (Opc == ISD::SMIN && Op0.getOpcode() == ISD::SMAX && Op0.hasOneUse()) {

0 commit comments

Comments
 (0)