Skip to content

Commit 49a0f2b

Browse files
Removed smed3/umed3 intrinsics; only keeping rocdl.fmed3.
Signed-off-by: keshavvinayak01 <[email protected]>
1 parent 5f8f446 commit 49a0f2b

File tree

14 files changed

+0
-457
lines changed

14 files changed

+0
-457
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ BUILTIN(__builtin_amdgcn_ds_bpermute, "iii", "nc")
139139
BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
140140
BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
141141
BUILTIN(__builtin_amdgcn_fmed3f, "ffff", "nc")
142-
BUILTIN(__builtin_amdgcn_smed3, "iiii", "nc")
143-
BUILTIN(__builtin_amdgcn_umed3, "UiUiUiUi", "nc")
144142
BUILTIN(__builtin_amdgcn_ds_faddf, "ff*3fIiIiIb", "n")
145143
BUILTIN(__builtin_amdgcn_ds_fminf, "ff*3fIiIiIb", "n")
146144
BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*3fIiIiIb", "n")
@@ -267,8 +265,6 @@ TARGET_BUILTIN(__builtin_amdgcn_perm, "UiUiUiUi", "nc", "gfx8-insts")
267265
//===----------------------------------------------------------------------===//
268266

269267
TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "hhhh", "nc", "gfx9-insts")
270-
TARGET_BUILTIN(__builtin_amdgcn_smed3h, "ssss", "nc", "gfx9-insts")
271-
TARGET_BUILTIN(__builtin_amdgcn_umed3h, "UsUsUsUs", "nc", "gfx9-insts")
272268

273269
TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f64, "dd*1d", "t", "gfx90a-insts")
274270
TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f32, "ff*1f", "t", "atomic-fadd-rtn-insts")

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,6 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
606606
case AMDGPU::BI__builtin_amdgcn_fmed3h:
607607
return emitBuiltinWithOneOverloadedType<3>(*this, E,
608608
Intrinsic::amdgcn_fmed3);
609-
case AMDGPU::BI__builtin_amdgcn_smed3:
610-
case AMDGPU::BI__builtin_amdgcn_smed3h:
611-
return emitBuiltinWithOneOverloadedType<3>(*this, E,
612-
Intrinsic::amdgcn_smed3);
613-
case AMDGPU::BI__builtin_amdgcn_umed3:
614-
case AMDGPU::BI__builtin_amdgcn_umed3h:
615-
return emitBuiltinWithOneOverloadedType<3>(*this, E,
616-
Intrinsic::amdgcn_umed3);
617609
case AMDGPU::BI__builtin_amdgcn_ds_append:
618610
case AMDGPU::BI__builtin_amdgcn_ds_consume: {
619611
Intrinsic::ID Intrin = BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_append ?

llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,6 @@ def int_amdgcn_fmed3 :
543543
[IntrNoMem, IntrSpeculatable]
544544
>;
545545

546-
def int_amdgcn_smed3 :
547-
DefaultAttrsIntrinsic<[llvm_anyint_ty],
548-
[LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
549-
[IntrNoMem, IntrSpeculatable]
550-
>;
551-
552-
def int_amdgcn_umed3 :
553-
DefaultAttrsIntrinsic<[llvm_anyint_ty],
554-
[LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
555-
[IntrNoMem, IntrSpeculatable]
556-
>;
557-
558546
def int_amdgcn_cubeid : ClangBuiltin<"__builtin_amdgcn_cubeid">,
559547
DefaultAttrsIntrinsic<[llvm_float_ty],
560548
[llvm_float_ty, llvm_float_ty, llvm_float_ty],

llvm/lib/Target/AMDGPU/AMDGPUGISel.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ def : GINodeEquiv<G_AMDGPU_CVT_F32_UBYTE2, AMDGPUcvt_f32_ubyte2>;
256256
def : GINodeEquiv<G_AMDGPU_CVT_F32_UBYTE3, AMDGPUcvt_f32_ubyte3>;
257257

258258
def : GINodeEquiv<G_AMDGPU_CVT_PK_I16_I32, AMDGPUpk_i16_i32_impl>;
259-
def : GINodeEquiv<G_AMDGPU_SMED3, AMDGPUsmed3_impl>;
260-
def : GINodeEquiv<G_AMDGPU_UMED3, AMDGPUumed3_impl>;
261259
def : GINodeEquiv<G_AMDGPU_FMED3, AMDGPUfmed3_impl>;
262260
def : GINodeEquiv<G_AMDGPU_CLAMP, AMDGPUclamp>;
263261

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 0 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,6 @@ static APFloat fmed3AMDGCN(const APFloat &Src0, const APFloat &Src1,
6060
return maxnum(Src0, Src1);
6161
}
6262

63-
// Constant fold llvm.amdgcn.smed3 intrinsics for standard inputs.
64-
static APInt smed3AMDGCN(const APInt &Src0, const APInt &Src1, const APInt &Src2) {
65-
APInt Max3 = Src0.sgt(Src1) ? (Src0.sgt(Src2) ? Src0 : Src2)
66-
: (Src1.sgt(Src2) ? Src1 : Src2);
67-
68-
if (Max3 == Src0) return Src1.sgt(Src2) ? Src1 : Src2;
69-
if (Max3 == Src1) return Src0.sgt(Src2) ? Src0 : Src2;
70-
return Src0.sgt(Src1) ? Src0 : Src1;
71-
}
72-
73-
// Constant fold llvm.amdgcn.umed3 intrinsics for standard inputs.
74-
static APInt umed3AMDGCN(const APInt &Src0, const APInt &Src1, const APInt &Src2) {
75-
APInt Max3 = Src0.ugt(Src1) ? (Src0.ugt(Src2) ? Src0 : Src2)
76-
: (Src1.ugt(Src2) ? Src1 : Src2);
77-
78-
if (Max3 == Src0) return Src1.ugt(Src2) ? Src1 : Src2;
79-
if (Max3 == Src1) return Src0.ugt(Src2) ? Src0 : Src2;
80-
return Src0.ugt(Src1) ? Src0 : Src1;
81-
}
82-
8363
// Check if a value can be converted to a 16-bit value without losing
8464
// precision.
8565
// The value is expected to be either a float (IsFloat = true) or an unsigned
@@ -447,36 +427,6 @@ static Value *matchFPExtFromF16(Value *Arg) {
447427
return nullptr;
448428
}
449429

450-
/// Match an sext from i16 to i32, or a constant we can convert.
451-
static Value *matchSExtFromI16(Value *Arg) {
452-
Value *Src = nullptr;
453-
ConstantInt *CInt = nullptr;
454-
if (match(Arg, m_OneUse(m_SExt(m_Value(Src))))) {
455-
if (Src->getType()->isIntegerTy(16))
456-
return Src;
457-
} else if (match(Arg, m_ConstantInt(CInt))) {
458-
// Check if the constant fits in i16
459-
if (CInt->getValue().getActiveBits() <= 16)
460-
return ConstantInt::get(Type::getInt16Ty(Arg->getContext()), CInt->getValue().trunc(16));
461-
}
462-
return nullptr;
463-
}
464-
465-
/// Match a zext from i16 to i32, or a constant we can convert.
466-
static Value *matchZExtFromI16(Value *Arg) {
467-
Value *Src = nullptr;
468-
ConstantInt *CInt = nullptr;
469-
if (match(Arg, m_OneUse(m_ZExt(m_Value(Src))))) {
470-
if (Src->getType()->isIntegerTy(16))
471-
return Src;
472-
} else if (match(Arg, m_ConstantInt(CInt))) {
473-
// Check if the constant fits in i16
474-
if (CInt->getValue().getActiveBits() <= 16)
475-
return ConstantInt::get(Type::getInt16Ty(Arg->getContext()), CInt->getValue().trunc(16));
476-
}
477-
return nullptr;
478-
}
479-
480430
// Trim all zero components from the end of the vector \p UseV and return
481431
// an appropriate bitset with known elements.
482432
static APInt trimTrailingZerosInVector(InstCombiner &IC, Value *UseV,
@@ -1224,128 +1174,6 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
12241174

12251175
break;
12261176
}
1227-
case Intrinsic::amdgcn_smed3: {
1228-
Value *Src0 = II.getArgOperand(0);
1229-
Value *Src1 = II.getArgOperand(1);
1230-
Value *Src2 = II.getArgOperand(2);
1231-
1232-
// Propagate poison values.
1233-
for (Value *Src : {Src0, Src1, Src2}) {
1234-
if (isa<PoisonValue>(Src))
1235-
return IC.replaceInstUsesWith(II, Src);
1236-
}
1237-
1238-
bool Swap = false;
1239-
// Canonicalize constants to RHS operands.
1240-
//
1241-
// smed3(c0, x, c1) -> smed3(x, c0, c1)
1242-
if (isa<Constant>(Src0) && !isa<Constant>(Src1)) {
1243-
std::swap(Src0, Src1);
1244-
Swap = true;
1245-
}
1246-
1247-
if (isa<Constant>(Src1) && !isa<Constant>(Src2)) {
1248-
std::swap(Src1, Src2);
1249-
Swap = true;
1250-
}
1251-
1252-
if (isa<Constant>(Src0) && !isa<Constant>(Src1)) {
1253-
std::swap(Src0, Src1);
1254-
Swap = true;
1255-
}
1256-
1257-
if (Swap) {
1258-
II.setArgOperand(0, Src0);
1259-
II.setArgOperand(1, Src1);
1260-
II.setArgOperand(2, Src2);
1261-
return &II;
1262-
}
1263-
1264-
// Constant fold smed3 with constant operands.
1265-
if (const ConstantInt *C0 = dyn_cast<ConstantInt>(Src0)) {
1266-
if (const ConstantInt *C1 = dyn_cast<ConstantInt>(Src1)) {
1267-
if (const ConstantInt *C2 = dyn_cast<ConstantInt>(Src2)) {
1268-
APInt Result = smed3AMDGCN(C0->getValue(), C1->getValue(), C2->getValue());
1269-
return IC.replaceInstUsesWith(II, ConstantInt::get(II.getType(), Result));
1270-
}
1271-
}
1272-
}
1273-
1274-
// Width reduction for integer extensions.
1275-
// smed3((sext X), (sext Y), (sext Z)) -> sext (smed3(X, Y, Z))
1276-
if (Value *X = matchSExtFromI16(Src0)) {
1277-
if (Value *Y = matchSExtFromI16(Src1)) {
1278-
if (Value *Z = matchSExtFromI16(Src2)) {
1279-
Value *NewCall = IC.Builder.CreateIntrinsic(
1280-
IID, {X->getType()}, {X, Y, Z}, &II, II.getName());
1281-
return new SExtInst(NewCall, II.getType());
1282-
}
1283-
}
1284-
}
1285-
1286-
break;
1287-
}
1288-
case Intrinsic::amdgcn_umed3: {
1289-
Value *Src0 = II.getArgOperand(0);
1290-
Value *Src1 = II.getArgOperand(1);
1291-
Value *Src2 = II.getArgOperand(2);
1292-
1293-
// Propagate poison values.
1294-
for (Value *Src : {Src0, Src1, Src2}) {
1295-
if (isa<PoisonValue>(Src))
1296-
return IC.replaceInstUsesWith(II, Src);
1297-
}
1298-
1299-
bool Swap = false;
1300-
// Canonicalize constants to RHS operands.
1301-
//
1302-
// umed3(c0, x, c1) -> umed3(x, c0, c1)
1303-
if (isa<Constant>(Src0) && !isa<Constant>(Src1)) {
1304-
std::swap(Src0, Src1);
1305-
Swap = true;
1306-
}
1307-
1308-
if (isa<Constant>(Src1) && !isa<Constant>(Src2)) {
1309-
std::swap(Src1, Src2);
1310-
Swap = true;
1311-
}
1312-
1313-
if (isa<Constant>(Src0) && !isa<Constant>(Src1)) {
1314-
std::swap(Src0, Src1);
1315-
Swap = true;
1316-
}
1317-
1318-
if (Swap) {
1319-
II.setArgOperand(0, Src0);
1320-
II.setArgOperand(1, Src1);
1321-
II.setArgOperand(2, Src2);
1322-
return &II;
1323-
}
1324-
1325-
// Constant fold umed3 with constant operands.
1326-
if (const ConstantInt *C0 = dyn_cast<ConstantInt>(Src0)) {
1327-
if (const ConstantInt *C1 = dyn_cast<ConstantInt>(Src1)) {
1328-
if (const ConstantInt *C2 = dyn_cast<ConstantInt>(Src2)) {
1329-
APInt Result = umed3AMDGCN(C0->getValue(), C1->getValue(), C2->getValue());
1330-
return IC.replaceInstUsesWith(II, ConstantInt::get(II.getType(), Result));
1331-
}
1332-
}
1333-
}
1334-
1335-
// Width reduction for integer extensions.
1336-
// umed3((zext X), (zext Y), (zext Z)) -> zext (umed3(X, Y, Z))
1337-
if (Value *X = matchZExtFromI16(Src0)) {
1338-
if (Value *Y = matchZExtFromI16(Src1)) {
1339-
if (Value *Z = matchZExtFromI16(Src2)) {
1340-
Value *NewCall = IC.Builder.CreateIntrinsic(
1341-
IID, {X->getType()}, {X, Y, Z}, &II, II.getName());
1342-
return new ZExtInst(NewCall, II.getType());
1343-
}
1344-
}
1345-
}
1346-
1347-
break;
1348-
}
13491177
case Intrinsic::amdgcn_icmp:
13501178
case Intrinsic::amdgcn_fcmp: {
13511179
const ConstantInt *CC = cast<ConstantInt>(II.getArgOperand(2));

llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ def AMDGPUmad_i24 : SDNode<"AMDGPUISD::MAD_I24", AMDGPUDTIntTernaryOp,
337337

338338
def AMDGPUfmed3_impl : SDNode<"AMDGPUISD::FMED3", SDTFPTernaryOp, []>;
339339

340-
def AMDGPUsmed3_impl : SDNode<"AMDGPUISD::SMED3", AMDGPUDTIntTernaryOp, []>;
341-
342-
def AMDGPUumed3_impl : SDNode<"AMDGPUISD::UMED3", AMDGPUDTIntTernaryOp, []>;
343-
344340
def AMDGPUfdot2_impl : SDNode<"AMDGPUISD::FDOT2",
345341
SDTypeProfile<1, 4, [SDTCisSameAs<0, 3>, SDTCisSameAs<1, 2>,
346342
SDTCisFP<0>, SDTCisVec<1>,
@@ -445,14 +441,6 @@ def AMDGPUfmed3 : PatFrags<(ops node:$src0, node:$src1, node:$src2),
445441
[(int_amdgcn_fmed3 node:$src0, node:$src1, node:$src2),
446442
(AMDGPUfmed3_impl node:$src0, node:$src1, node:$src2)]>;
447443

448-
def AMDGPUsmed3 : PatFrags<(ops node:$src0, node:$src1, node:$src2),
449-
[(int_amdgcn_smed3 node:$src0, node:$src1, node:$src2),
450-
(AMDGPUsmed3_impl node:$src0, node:$src1, node:$src2)]>;
451-
452-
def AMDGPUumed3 : PatFrags<(ops node:$src0, node:$src1, node:$src2),
453-
[(int_amdgcn_umed3 node:$src0, node:$src1, node:$src2),
454-
(AMDGPUumed3_impl node:$src0, node:$src1, node:$src2)]>;
455-
456444
def AMDGPUdiv_fixup : PatFrags<(ops node:$src0, node:$src1, node:$src2),
457445
[(int_amdgcn_div_fixup node:$src0, node:$src1, node:$src2),
458446
(AMDGPUdiv_fixup_impl node:$src0, node:$src1, node:$src2)]>;

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7798,28 +7798,6 @@ bool AMDGPULegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
77987798
Observer.changedInstr(MI);
77997799
return true;
78007800
}
7801-
case Intrinsic::amdgcn_smed3: {
7802-
GISelChangeObserver &Observer = Helper.Observer;
7803-
7804-
// FIXME: This is to workaround the inability of tablegen match combiners to
7805-
// match intrinsics in patterns.
7806-
Observer.changingInstr(MI);
7807-
MI.setDesc(B.getTII().get(AMDGPU::G_AMDGPU_SMED3));
7808-
MI.removeOperand(1);
7809-
Observer.changedInstr(MI);
7810-
return true;
7811-
}
7812-
case Intrinsic::amdgcn_umed3: {
7813-
GISelChangeObserver &Observer = Helper.Observer;
7814-
7815-
// FIXME: This is to workaround the inability of tablegen match combiners to
7816-
// match intrinsics in patterns.
7817-
Observer.changingInstr(MI);
7818-
MI.setDesc(B.getTII().get(AMDGPU::G_AMDGPU_UMED3));
7819-
MI.removeOperand(1);
7820-
Observer.changedInstr(MI);
7821-
return true;
7822-
}
78237801
case Intrinsic::amdgcn_readlane:
78247802
case Intrinsic::amdgcn_writelane:
78257803
case Intrinsic::amdgcn_readfirstlane:

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4136,7 +4136,6 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
41364136
case AMDGPU::G_AMDGPU_CVT_F32_UBYTE3:
41374137
case AMDGPU::G_AMDGPU_CVT_PK_I16_I32:
41384138
case AMDGPU::G_AMDGPU_SMED3:
4139-
case AMDGPU::G_AMDGPU_UMED3:
41404139
case AMDGPU::G_AMDGPU_FMED3:
41414140
return getDefaultMappingVOP(MI);
41424141
case AMDGPU::G_UMULH:
@@ -4661,8 +4660,6 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
46614660
case Intrinsic::amdgcn_cvt_scalef32_sr_pk16_bf6_bf16:
46624661
case Intrinsic::amdgcn_sat_pk4_i4_i8:
46634662
case Intrinsic::amdgcn_sat_pk4_u4_u8:
4664-
case Intrinsic::amdgcn_smed3:
4665-
case Intrinsic::amdgcn_umed3:
46664663
case Intrinsic::amdgcn_fmed3:
46674664
case Intrinsic::amdgcn_cubeid:
46684665
case Intrinsic::amdgcn_cubema:

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.smed3.i16.ll

Lines changed: 0 additions & 27 deletions
This file was deleted.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.smed3.ll

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)