[InstCombine][NFC] Tests for 'unsigned sub overflow' check
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 5 Sep 2019 17:40:37 +0000 (17:40 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 5 Sep 2019 17:40:37 +0000 (17:40 +0000)
commit80a5702b83eb4c6fb9f0d8674107a1cb4e990006
treebdd5f161c641e7ed3677bb60d12b2059323762e4
parentdaf74d92cf1e728d9d073d7d974501103e43a6a0
[InstCombine][NFC] Tests for 'unsigned sub overflow' check

----------------------------------------
Name: unsigned sub, overflow, v0
  %sub = sub i8 %x, %y
  %ov = icmp ugt i8 %sub, %x
=>
  %agg = usub_overflow i8 %x, %y
  %sub = extractvalue {i8, i1} %agg, 0
  %ov = extractvalue {i8, i1} %agg, 1

Done: 1
Optimization is correct!

----------------------------------------
Name: unsigned sub, no overflow, v0
  %sub = sub i8 %x, %y
  %ov = icmp ule i8 %sub, %x
=>
  %agg = usub_overflow i8 %x, %y
  %sub = extractvalue {i8, i1} %agg, 0
  %not.ov = extractvalue {i8, i1} %agg, 1
  %ov = xor %not.ov, -1

Done: 1
Optimization is correct!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371099 91177308-0d34-0410-b5e6-96231b3b80d8
test/Transforms/InstCombine/unsigned-sub-lack-of-overflow-check.ll [new file with mode: 0644]
test/Transforms/InstCombine/unsigned-sub-overflow-check.ll [new file with mode: 0644]