[InstSimplify] allow undefs in icmp with vector constant folds
authorSanjay Patel <spatel@rotateright.com>
Tue, 28 Jul 2020 19:13:19 +0000 (15:13 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 28 Jul 2020 19:13:53 +0000 (15:13 -0400)
commit3fb13b8484dcbec085da047879bf89ccb1b65b12
treeb3917ab66186e880e5e4ccb84b3e6e77bcd9c6fc
parent67dfba96296b37f7bac9b4a68572288bc44b63b2
[InstSimplify] allow undefs in icmp with vector constant folds

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_

Differential Revision: https://reviews.llvm.org/D84762
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/icmp-constant.ll