@@ -5957,8 +5957,8 @@ SDValue SITargetLowering::lowerROTR(SDValue Op, SelectionDAG &DAG) const {
5957
5957
unsigned VectorSize = VT.getVectorNumElements();
5958
5958
EVT ElementType = VT.getVectorElementType();
5959
5959
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);
5962
5962
5963
5963
SmallVector<SDValue, 4> RotateTargets;
5964
5964
SmallVector<SDValue, 4> RotateSizes;
@@ -12921,41 +12921,47 @@ SDValue SITargetLowering::performOrCombine(SDNode *N,
12921
12921
12922
12922
// Detect identity v2i32 OR and replace with identity source node.
12923
12923
// 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
12925
12937
if (VT == MVT::v2i32) {
12926
12938
if (LHS->getOpcode() == ISD::BUILD_VECTOR &&
12927
12939
RHS->getOpcode() == ISD::BUILD_VECTOR) {
12928
12940
LLVM_DEBUG(dbgs() << "### Performing v2i32 SIISelLowering "
12929
12941
"DAGCombine::CombineOR\n";);
12930
12942
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
+ }
12955
12962
}
12956
12963
}
12957
12964
}
12958
- }
12959
12965
}
12960
12966
}
12961
12967
0 commit comments