This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] [NFC] Add tests for peeking through unsigned FP casts for zero-equality compares (PR36682)
ClosedPublic

Authored by lebedev.ri on Mar 13 2018, 4:35 AM.

Details

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 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 can be dropped:

  • eq 0
  • ne 0

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

Diff Detail

Repository
rL LLVM

Event Timeline

lebedev.ri created this revision.Mar 13 2018, 4:35 AM
spatel accepted this revision.Mar 13 2018, 6:39 AM

LGTM - although I think it would be more useful and more compact to have 1 or 2 vector tests at the end with a zeroinitializer constant followed by 1 or 2 vector tests with an undef element in the constant. This will show that we already do support vector types; we're just lacking the last piece of the puzzle - discounting undef elements (and I'll try to fix that soon).

And as I said before, if we verify that at least one case works with vectors, then it's a good bet that all of these cases work with vectors.

This revision is now accepted and ready to land.Mar 13 2018, 6:39 AM

Reduced amounts of test patterns, while improving test coverage:

  • one single input type - i32
  • still three sizes it's cast to - half/i16, float/i32, double/i64 - so we do have cast/upcast/downcast cases
  • scalar, vector case with undef element, and added vector without undef Since the <i32 0, i32 0> is canonicalized to zeroinitializer, i did not add explicit test with zeroinitializer.

I could selectively manually prune some more testcases, if needed.

This revision was automatically updated to reflect the committed changes.