This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] allow undefs in icmp with vector constant folds
ClosedPublic

Authored by spatel on Jul 28 2020, 8:36 AM.

Details

Summary

I think this is safe, but I've been wrong before...
This is the main icmp simplification shortcoming seen in D84655.

Alive2 agrees that the basic examples are correct at least:

define <2 x i1> @src(<2 x i8> %x) {
%0:
  %r = icmp sle <2 x i8> { undef, 128 }, %x
  ret <2 x i1> %r
}
=>
define <2 x i1> @tgt(<2 x i8> %x) {
%0:
  ret <2 x i1> { 1, 1 }
}
Transformation seems to be correct!

define <2 x i1> @src(<2 x i32> %X) {
%0:
  %A = or <2 x i32> %X, { 63, 63 }
  %B = icmp ult <2 x i32> %A, { undef, 50 }
  ret <2 x i1> %B
}
=>
define <2 x i1> @tgt(<2 x i32> %X) {
%0:
  ret <2 x i1> { 0, 0 }
}
Transformation seems to be correct!

https://alive2.llvm.org/ce/z/omt2ee
https://alive2.llvm.org/ce/z/GW4nP_

Diff Detail

Event Timeline

spatel created this revision.Jul 28 2020, 8:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2020, 8:36 AM
spatel requested review of this revision.Jul 28 2020, 8:36 AM
aqjune accepted this revision.Jul 28 2020, 9:04 AM

Looks good to me.
I'm not familiar with the use of m_APIntAllowUndef, so one more accept would be enough IMO.

This revision is now accepted and ready to land.Jul 28 2020, 9:04 AM
nikic accepted this revision.Jul 28 2020, 10:23 AM

LG as well.