[ValueTracking] usub(a, b) cannot overflow if a >= b.
authorFlorian Hahn <flo@fhahn.com>
Fri, 7 Feb 2020 10:31:35 +0000 (10:31 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 7 Feb 2020 10:41:18 +0000 (10:41 +0000)
commit14ef87bda67d53f351217c4522150e41fb5695e8
tree011025f5ee49812fc927437a72365aafa49685a2
parent74734e809ac778beb01776ee207643184c09c2a0
[ValueTracking] usub(a, b) cannot overflow if a >= b.

If we know that a >= b (unsigned), usub.with.overflow(a, b) cannot
overflow. Similarly, if b > a, the same expression overflows.

Reviewers: nikic, RKSimon, lebedev.ri, spatel

Reviewed By: nikic, Gerolf

Differential Revision: https://reviews.llvm.org/D74066
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/usub-overflow-known-by-implied-cond.ll