Skip to content

Commit e973680

Browse files
committed
Fix unassigned add handling in aarch64
1 parent 032c328 commit e973680

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5236,6 +5236,13 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
52365236
DAG.getNode(ISD::ADD, DL, VT, N0, DAG.getAllOnesConstant(DL, VT)));
52375237
}
52385238

5239+
// Fold avgfloors(x,y) -> avgflooru(x,y) if both x and y are non-negative
5240+
if (Opcode == ISD::AVGFLOORS && !hasOperation(ISD::AVGFLOORS, VT) &&
5241+
(!LegalOperations || hasOperation(ISD::AVGFLOORU, VT))) {
5242+
if (DAG.SignBitIsZero(N0) && DAG.SignBitIsZero(N1))
5243+
return DAG.getNode(ISD::AVGFLOORU, DL, VT, N0, N1);
5244+
}
5245+
52395246
return SDValue();
52405247
}
52415248

0 commit comments

Comments
 (0)