Skip to content

Commit b61f74e

Browse files
committed
[DAGCombiner] Explain why we recreate ADD
1 parent 74ca22c commit b61f74e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12142,12 +12142,15 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
1214212142
if (sd_match(Cond1, m_ConstInt(C)) && hasUMin(VT)) {
1214312143
if (CC == ISD::SETUGT && Cond0 == N2 &&
1214412144
sd_match(N1, m_Add(m_Specific(N2), m_SpecificInt(~C)))) {
12145+
// The resulting code relies on an unsigned wrap in ADD.
12146+
// Recreating ADD to drop possible nuw/nsw flags.
1214512147
SDValue AddC = DAG.getConstant(~C, DL, VT);
1214612148
SDValue Add = DAG.getNode(ISD::ADD, DL, VT, N2, AddC);
1214712149
return DAG.getNode(ISD::UMIN, DL, VT, Add, N2);
1214812150
}
1214912151
if (CC == ISD::SETULT && Cond0 == N1 &&
1215012152
sd_match(N2, m_Add(m_Specific(N1), m_SpecificInt(-C)))) {
12153+
// Ditto.
1215112154
SDValue AddC = DAG.getConstant(-C, DL, VT);
1215212155
SDValue Add = DAG.getNode(ISD::ADD, DL, VT, N1, AddC);
1215312156
return DAG.getNode(ISD::UMIN, DL, VT, N1, Add);

0 commit comments

Comments
 (0)