[InstCombine] reduce sub-with-overflow ==/!= 0
authorSanjay Patel <spatel@rotateright.com>
Mon, 15 Aug 2022 16:25:24 +0000 (12:25 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 15 Aug 2022 17:03:51 +0000 (13:03 -0400)
commite5748c6e73e7a3173046002b1f9a556965552c37
treee610c06eb76782bd4bca5e0c5f89d8a523fb41ec
parentb4f61c5ecdad54cb145f8ec339cf3924514ac3c3
[InstCombine] reduce sub-with-overflow ==/!= 0

The basic patterns look like this:
https://alive2.llvm.org/ce/z/MDj9EC

The tests have a use of the overflow value too.
Otherwise, existing folds should reduce already.

This was noted as a missing IR fold in:
926e7312b2f20f2f7b

Hopefully, this makes it easier to implement a backend
fix because we should get the same IR regardless of
whether the source used builtins or inline code.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/ssubo.ll
llvm/test/Transforms/InstCombine/usubo.ll