Skip to content

Commit d1afe09

Browse files
committed
Respond to some reviewer comments
1 parent 5cedf25 commit d1afe09

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5957,8 +5957,8 @@ SDValue SITargetLowering::lowerROTR(SDValue Op, SelectionDAG &DAG) const {
59575957
unsigned VectorSize = VT.getVectorNumElements();
59585958
EVT ElementType = VT.getVectorElementType();
59595959
SDLoc SL(Op);
5960-
auto LHS = Op->getOperand(0);
5961-
auto RHS = Op->getOperand(1);
5960+
const SDValue &LHS = Op->getOperand(0);
5961+
const SDValue &RHS = Op->getOperand(1);
59625962

59635963
SmallVector<SDValue, 4> RotateTargets;
59645964
SmallVector<SDValue, 4> RotateSizes;
@@ -12921,41 +12921,47 @@ SDValue SITargetLowering::performOrCombine(SDNode *N,
1292112921

1292212922
// Detect identity v2i32 OR and replace with identity source node.
1292312923
// Specifically an Or that has operands constructed from the same source node
12924-
// via extract_vector_elt and build_vector.
12924+
// via extract_vector_elt and build_vector. I.E.
12925+
// v2i32 or(
12926+
// v2i32 build_vector(
12927+
// i32 extract_elt(%IdentitySrc, 0),
12928+
// i32 0
12929+
// ),
12930+
// v2i32 build_vector(
12931+
// i32 0,
12932+
// i32 extract_elt(%IdentitySrc, 1)
12933+
// )
12934+
// )
12935+
// =>
12936+
// v2i32 %IdentitySrc
1292512937
if (VT == MVT::v2i32) {
1292612938
if (LHS->getOpcode() == ISD::BUILD_VECTOR &&
1292712939
RHS->getOpcode() == ISD::BUILD_VECTOR) {
1292812940
LLVM_DEBUG(dbgs() << "### Performing v2i32 SIISelLowering "
1292912941
"DAGCombine::CombineOR\n";);
1293012942

12931-
auto *LC = dyn_cast<ConstantSDNode>(LHS->getOperand(1));
12932-
auto *RC = dyn_cast<ConstantSDNode>(RHS->getOperand(0));
12933-
12934-
if (LC && RC) {
12935-
12936-
// Test for and normalise build vectors.
12937-
if (LHS->getOpcode() == ISD::BUILD_VECTOR &&
12938-
RHS->getOpcode() == ISD::BUILD_VECTOR &&
12939-
// Check cast to constantnode here
12940-
LHS->getConstantOperandVal(1) == 0 &&
12941-
RHS->getConstantOperandVal(0) == 0) {
12942-
12943-
// Get the extract_vector_element operands.
12944-
SDValue LEVE = LHS->getOperand(0);
12945-
SDValue REVE = RHS->getOperand(1);
12946-
12947-
if (LEVE->getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
12948-
REVE->getOpcode() == ISD::EXTRACT_VECTOR_ELT) {
12949-
// Check that the the elements from the same vector are extracted.
12950-
if (LEVE->getOperand(0) == REVE->getOperand(0) &&
12951-
LEVE->getOperand(1) != REVE->getOperand(1)) {
12952-
LLVM_DEBUG(dbgs() << "### Found identity OR, folding...\n";);
12953-
SDValue IdentitySrc = LEVE.getOperand(0);
12954-
return IdentitySrc;
12943+
if (auto *LC = dyn_cast<ConstantSDNode>(LHS->getOperand(1)))
12944+
if (auto *RC = dyn_cast<ConstantSDNode>(RHS->getOperand(0))) {
12945+
12946+
// Test for and normalise build vectors.
12947+
if (LC->getZExtValue() == 0 && RC->getZExtValue() == 0) {
12948+
12949+
// Get the extract_vector_element operands.
12950+
SDValue LEVE = LHS->getOperand(0);
12951+
SDValue REVE = RHS->getOperand(1);
12952+
12953+
if (LEVE->getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
12954+
REVE->getOpcode() == ISD::EXTRACT_VECTOR_ELT) {
12955+
// Check that different elements from the same vector are extracted.
12956+
if (LEVE->getOperand(0) == REVE->getOperand(0) &&
12957+
LEVE->getOperand(1) != REVE->getOperand(1)) {
12958+
LLVM_DEBUG(dbgs() << "### Found identity OR, folding...\n";);
12959+
SDValue IdentitySrc = LEVE.getOperand(0);
12960+
return IdentitySrc;
12961+
}
1295512962
}
1295612963
}
1295712964
}
12958-
}
1295912965
}
1296012966
}
1296112967

0 commit comments

Comments
 (0)