diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-09-05 17:41:02 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-09-05 17:41:02 +0000 |
commit | 8360c42e25108450184fbfb93870fecd0d21e6f4 (patch) | |
tree | 60e599ca122ff997b3cc69600caf9a8efed36b3b /llvm/lib/Support/FileUtilities.cpp | |
parent | ecb7ea1ae7c6658771f6de4a957f0ddcc1cf4a8d (diff) | |
download | llvm-8360c42e25108450184fbfb93870fecd0d21e6f4.zip llvm-8360c42e25108450184fbfb93870fecd0d21e6f4.tar.gz llvm-8360c42e25108450184fbfb93870fecd0d21e6f4.tar.bz2 |
[InstCombine] foldICmpBinOp(): consider inverted check in 'unsigned sub overflow' check
A follow-up for r329011.
This may be changed to produce @llvm.sub.with.overflow in a later patch,
but for now just make things more consistent overall.
A few observations stem from this:
* There does not seem to be a similar one-instruction fold for uadd-overflow
* I'm not sure we'll want to canonicalize `B u> A` as `usub.with.overflow`,
so since the `icmp` here no longer refers to `sub`,
reconstructing `usub.with.overflow` will be problematic,
and will likely require standalone pass (similar to DivRemPairs).
https://rise4fun.com/Alive/Zqs
Name: (A - B) u> A --> B u> A
%t0 = sub i8 %A, %B
%r = icmp ugt i8 %t0, %A
=>
%r = icmp ugt i8 %B, %A
Name: (A - B) u<= A --> B u<= A
%t0 = sub i8 %A, %B
%r = icmp ule i8 %t0, %A
=>
%r = icmp ule i8 %B, %A
Name: C u< (C - D) --> C u< D
%t0 = sub i8 %C, %D
%r = icmp ult i8 %C, %t0
=>
%r = icmp ult i8 %C, %D
Name: C u>= (C - D) --> C u>= D
%t0 = sub i8 %C, %D
%r = icmp uge i8 %C, %t0
=>
%r = icmp uge i8 %C, %D
llvm-svn: 371101
Diffstat (limited to 'llvm/lib/Support/FileUtilities.cpp')
0 files changed, 0 insertions, 0 deletions