Check AlwaysOverflow condition for usubo. The implementation is the same as the existing handling for uaddo and umulo. Handling for saddo and ssubo will follow (smulo doesn't have the necessary ValueTracking support).
Details
Diff Detail
Event Timeline
Looks good, consider landing as two commits.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
3940 | Hm, i should check if this can be used (or is already used?) for some of the implicit-conversion checks that aren't using overflow intrinsics, but plain ir.. | |
3993 | And willNotOverflowUnsignedSub() is: (unless i'm looking at the wrong func?) bool willNotOverflowUnsignedSub(const Value *LHS, const Value *RHS, const Instruction &CxtI) const { return computeOverflowForUnsignedSub(LHS, RHS, &CxtI) == OverflowResult::NeverOverflows; } So this should ideally be: - if (willNotOverflowUnsignedSub(LHS, RHS, OrigI)) + OverflowResult OR = computeOverflowForUnsignedSub(LHS, RHS, &OrigI); + if (OR == OverflowResult::NeverOverflows) patch 1 - + if (OR == OverflowResult::AlwaysOverflows) + return SetResult(Builder.CreateSub(LHS, RHS), Builder.getTrue(), true); |
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
3940 | Apart from with.overflow handling this function is used in one more place: https://github.com/llvm-mirror/llvm/blob/29ea2070bd62816674f48ac392a1ee24e5c915cf/lib/Transforms/InstCombine/InstCombineCompares.cpp#L5049-L5060 Not sure if that's the usage you have in mind. | |
3993 | I've split out the willNot -> computeOverflow change (for all cases) into rL358051. |
Hm, i should check if this can be used (or is already used?) for some of the implicit-conversion checks that aren't using overflow intrinsics, but plain ir..