[InstSimplify] [NFC] Add tests for peeking through unsigned FP casts for sign compare...
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 14 Mar 2018 17:31:08 +0000 (17:31 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 14 Mar 2018 17:31:08 +0000 (17:31 +0000)
commit978aae761422e97620a2d9bebe52cd6f4b963a4b
treee5db0ce24bdf3771a1f7b654ea95e16974954184
parent6ab60358ca6395da47d85c8368798e7c93f2c3ba
[InstSimplify] [NFC] Add tests for peeking through unsigned FP casts for sign compares (PR36682)

Summary:
This pattern came up in PR36682 / D44390
https://bugs.llvm.org/show_bug.cgi?id=36682
https://reviews.llvm.org/D44390
https://godbolt.org/g/oKvT5H

Looking at the IR pattern in question, as per [[ https://github.com/rutgers-apl/alive-nj | alive-nj ]], for all the type combinations i checked
(input: `i16`, `i32`, `i64`; intermediate: `half`/`i16`, `float`/`i32`, `double`/`i64`)
for the following `icmp` comparisons the `uitofp`+`bitcast`+`icmp` can be evaluated to a boolean:
* `slt 0`
* `sgt -1`
I did not check vectors, but i'm guessing it's the same there.
{F5889242}

Thus all these cases are in the testcase (along with the vector variant with additional `undef` element in the middle).
There are no negative patterns here (unless alive-nj lied/is broken), all of these should be optimized.

Reviewers: spatel, majnemer, efriedma, arsenm

Reviewed By: spatel

Subscribers: wdng, llvm-commits

Differential Revision: https://reviews.llvm.org/D44421

llvm-svn: 327535
llvm/test/Transforms/InstSimplify/cast-unsigned-icmp-cmp-0.ll [new file with mode: 0644]