[PATCH] D44390: [InstCombine] [NFC] Add tests for peeking through FP casts for sign-bit compares (PR36682)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 12 08:50:09 PDT 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, majnemer, efriedma, arsenm.
Herald added a subscriber: wdng.

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

Tests for proposed fix in https://reviews.llvm.org/D44367.

Looking at the IR pattern in question, as per alive-nj <https://github.com/rutgers-apl/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 `sitofp`+`bitcast` can be dropped:

- `eq 0`
- `ne 0`
- `slt 0`
- `sle 0`
- `sge 0`
- `sgt 0`
- `slt 1`
- `sge 1`
- `sle -1`
- `sgt -1`

I did not check vectors, but i'm guessing it's the same there.
F5887419: alivenj-bitcast.txt <https://reviews.llvm.org/F5887419>

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.

Generated with F5887551: bitcast.cpp <https://reviews.llvm.org/F5887551>


Repository:
  rL LLVM

https://reviews.llvm.org/D44390

Files:
  test/Transforms/InstCombine/cast-int-icmp-eq-0.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44390.138023.patch
Type: text/x-patch
Size: 90876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180312/abbbe292/attachment-0001.bin>


More information about the llvm-commits mailing list