Skip to content

Commit cbf719b

Browse files
committed
AMDGPU: Use DAG patterns for div_fmas
1 parent 79b29d6 commit cbf719b

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ class AMDGPUDAGToDAGISel : public SelectionDAGISel {
278278
void SelectAddcSubb(SDNode *N);
279279
void SelectUADDO_USUBO(SDNode *N);
280280
void SelectDIV_SCALE(SDNode *N);
281-
void SelectDIV_FMAS(SDNode *N);
282281
void SelectMAD_64_32(SDNode *N);
283282
void SelectFMA_W_CHAIN(SDNode *N);
284283
void SelectFMUL_W_CHAIN(SDNode *N);
@@ -871,10 +870,6 @@ void AMDGPUDAGToDAGISel::Select(SDNode *N) {
871870
SelectDIV_SCALE(N);
872871
return;
873872
}
874-
case AMDGPUISD::DIV_FMAS: {
875-
SelectDIV_FMAS(N);
876-
return;
877-
}
878873
case AMDGPUISD::MAD_I64_I32:
879874
case AMDGPUISD::MAD_U64_U32: {
880875
SelectMAD_64_32(N);
@@ -1128,35 +1123,6 @@ void AMDGPUDAGToDAGISel::SelectDIV_SCALE(SDNode *N) {
11281123
CurDAG->SelectNodeTo(N, Opc, N->getVTList(), Ops);
11291124
}
11301125

1131-
void AMDGPUDAGToDAGISel::SelectDIV_FMAS(SDNode *N) {
1132-
const GCNSubtarget *ST = static_cast<const GCNSubtarget *>(Subtarget);
1133-
const SIRegisterInfo *TRI = ST->getRegisterInfo();
1134-
1135-
SDLoc SL(N);
1136-
EVT VT = N->getValueType(0);
1137-
1138-
assert(VT == MVT::f32 || VT == MVT::f64);
1139-
1140-
unsigned Opc
1141-
= (VT == MVT::f64) ? AMDGPU::V_DIV_FMAS_F64 : AMDGPU::V_DIV_FMAS_F32;
1142-
1143-
SDValue CarryIn = N->getOperand(3);
1144-
// V_DIV_FMAS implicitly reads VCC.
1145-
SDValue VCC = CurDAG->getCopyToReg(CurDAG->getEntryNode(), SL,
1146-
TRI->getVCC(), CarryIn, SDValue());
1147-
1148-
SDValue Ops[10];
1149-
1150-
SelectVOP3Mods0(N->getOperand(0), Ops[1], Ops[0], Ops[6], Ops[7]);
1151-
SelectVOP3Mods(N->getOperand(1), Ops[3], Ops[2]);
1152-
SelectVOP3Mods(N->getOperand(2), Ops[5], Ops[4]);
1153-
1154-
Ops[8] = VCC;
1155-
Ops[9] = VCC.getValue(1);
1156-
1157-
CurDAG->SelectNodeTo(N, Opc, N->getVTList(), Ops);
1158-
}
1159-
11601126
// We need to handle this here because tablegen doesn't support matching
11611127
// instructions with multiple outputs.
11621128
void AMDGPUDAGToDAGISel::SelectMAD_64_32(SDNode *N) {

llvm/lib/Target/AMDGPU/VOP3Instructions.td

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,24 @@ let SubtargetPredicate = isGFX10Plus in {
716716
V_PERMLANEX16_B32>;
717717
} // End SubtargetPredicate = isGFX10Plus
718718

719+
class DivFmasPat<ValueType vt, Instruction inst, Register CondReg> : GCNPat<
720+
(AMDGPUdiv_fmas (vt (VOP3Mods vt:$src0, i32:$src0_modifiers)),
721+
(VOP3Mods vt:$src1, i32:$src1_modifiers),
722+
(VOP3Mods vt:$src2, i32:$src2_modifiers),
723+
(i1 CondReg)),
724+
(inst $src0_modifiers, $src0, $src1_modifiers, $src1, $src2_modifiers, $src2)
725+
>;
726+
727+
let WaveSizePredicate = isWave64 in {
728+
def : DivFmasPat<f32, V_DIV_FMAS_F32, VCC>;
729+
def : DivFmasPat<f64, V_DIV_FMAS_F64, VCC>;
730+
}
731+
732+
let WaveSizePredicate = isWave32 in {
733+
def : DivFmasPat<f32, V_DIV_FMAS_F32, VCC_LO>;
734+
def : DivFmasPat<f64, V_DIV_FMAS_F64, VCC_LO>;
735+
}
736+
719737
//===----------------------------------------------------------------------===//
720738
// Integer Clamp Patterns
721739
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)