Skip to content

Commit 5648aa3

Browse files
committed
[DAGCombiner] Propagate nsw/nuw flags
1 parent 708a6ee commit 5648aa3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13905,7 +13905,10 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
1390513905
} else {
1390613906
// Op is i64, Mid is i8, and Dest is i32. If Op has more than 56 sign
1390713907
// bits, just truncate to i32.
13908-
return DAG.getNode(ISD::TRUNCATE, DL, VT, Op);
13908+
SDNodeFlags Flags;
13909+
Flags.setNoSignedWrap(true);
13910+
Flags.setNoUnsignedWrap(N0->getFlags().hasNoUnsignedWrap());
13911+
return DAG.getNode(ISD::TRUNCATE, DL, VT, Op, Flags);
1390913912
}
1391013913
}
1391113914

@@ -14192,7 +14195,10 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
1419214195
} else {
1419314196
// Op is i64, Mid is i8, and Dest is i32. If Op has more than 56 sign
1419414197
// bits, just truncate to i32.
14195-
return DAG.getNode(ISD::TRUNCATE, DL, VT, Op);
14198+
SDNodeFlags Flags;
14199+
Flags.setNoSignedWrap(true);
14200+
Flags.setNoUnsignedWrap(true);
14201+
return DAG.getNode(ISD::TRUNCATE, DL, VT, Op, Flags);
1419614202
}
1419714203
}
1419814204
}

0 commit comments

Comments
 (0)