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 D44367.
Looking at the IR pattern in question, as per 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.
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
As the current check line shows, this verifies that we canonicalize the predicate to 'slt'. Once that canonicalization is made, the test is identical to a later test (see below), so I don't think it's worth duplicating this or similar tests with sle/sge predicates. Remove all of those?