If we know that a >= b (unsigned), usub.with.overflow(a, b) cannot
overflow. Similarly, if b > a, the same expression overflows.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Unit tests: unknown.
clang-tidy: unknown.
clang-format: unknown.
Build artifacts: console-log.txt
Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
My only concern here is compile-time impact. Keep in mind that this function is not just being called for usub.with.overflow, but for every sub in the IR, trying to infer the nuw flag. As isImpliedByDomCondition() only inspects the direct predecessor, that's probably fine though.
Generally we're missing a pass that can propagate conditions and assumes with non-constant operands (CVP mostly covers the constant operand case)...
Updated to limit isImpliedByDomCond to usub.with.overflow calls for now.
Ah right! isImpliedByDomCondition should not be too expensive, but I've limited using it to usub.with.overflow for now.
Generally we're missing a pass that can propagate conditions and assumes with non-constant operands (CVP mostly covers the constant operand case)...
Agreed!
Unit tests: unknown.
clang-tidy: unknown.
clang-format: unknown.
Build artifacts: console-log.txt
Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
Unit tests: unknown.
clang-tidy: unknown.
clang-format: unknown.
Build artifacts: console-log.txt
Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
LG as well.
For what it's worth, I think doing this generally is also fine, but we should probably wait until it actually shows up in practice before enabling that.