[InstSimplify, InstCombine] add tests with vector undef elts; NFC

These would fold if the m_One pattern matcher accounted for undef elts.

llvm-svn: 325436
This commit is contained in:
Sanjay Patel 2018-02-17 15:55:40 +00:00
parent dbcbaee7fd
commit a6a1426cf1
2 changed files with 43 additions and 6 deletions

View File

@ -54,24 +54,33 @@ define i32 @test6(i1 %C) {
; CHECK: ret i32 %V
}
define i1 @test7(i1 %C, i1 %X) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: [[R:%.*]] = or i1 %C, %X
define i1 @trueval_is_true(i1 %C, i1 %X) {
; CHECK-LABEL: @trueval_is_true(
; CHECK-NEXT: [[R:%.*]] = or i1 [[C:%.*]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[R]]
;
%R = select i1 %C, i1 true, i1 %X
ret i1 %R
}
define <2 x i1> @test7vec(<2 x i1> %C, <2 x i1> %X) {
; CHECK-LABEL: @test7vec(
; CHECK-NEXT: [[R:%.*]] = or <2 x i1> %C, %X
define <2 x i1> @trueval_is_true_vec(<2 x i1> %C, <2 x i1> %X) {
; CHECK-LABEL: @trueval_is_true_vec(
; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[C:%.*]], [[X:%.*]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%R = select <2 x i1> %C, <2 x i1> <i1 true, i1 true>, <2 x i1> %X
ret <2 x i1> %R
}
define <2 x i1> @trueval_is_true_vec_undef_elt(<2 x i1> %C, <2 x i1> %X) {
; CHECK-LABEL: @trueval_is_true_vec_undef_elt(
; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[C:%.*]], <2 x i1> <i1 undef, i1 true>, <2 x i1> [[X:%.*]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%R = select <2 x i1> %C, <2 x i1> <i1 undef, i1 true>, <2 x i1> %X
ret <2 x i1> %R
}
define i1 @test8(i1 %C, i1 %X) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: [[R:%.*]] = and i1 %C, %X

View File

@ -1,3 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
; Test all integer predicates with bool types and true/false constants.
@ -11,6 +12,15 @@ define <2 x i1> @eq_t(<2 x i1> %a) {
ret <2 x i1> %r
}
define <2 x i1> @eq_t_undef_elt(<2 x i1> %a) {
; CHECK-LABEL: @eq_t_undef_elt(
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i1> [[A:%.*]], <i1 undef, i1 true>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%r = icmp eq <2 x i1> %a, <i1 undef, i1 true>
ret <2 x i1> %r
}
define <2 x i1> @eq_f(<2 x i1> %a) {
; CHECK-LABEL: @eq_f(
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i1> %a, zeroinitializer
@ -45,6 +55,15 @@ define <2 x i1> @ugt_t(<2 x i1> %a) {
ret <2 x i1> %r
}
define <2 x i1> @ugt_t_undef_elt(<2 x i1> %a) {
; CHECK-LABEL: @ugt_t_undef_elt(
; CHECK-NEXT: [[R:%.*]] = icmp ugt <2 x i1> [[A:%.*]], <i1 true, i1 undef>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%r = icmp ugt <2 x i1> %a, <i1 true, i1 undef>
ret <2 x i1> %r
}
define <2 x i1> @ugt_f(<2 x i1> %a) {
; CHECK-LABEL: @ugt_f(
; CHECK-NEXT: ret <2 x i1> %a
@ -144,6 +163,15 @@ define <2 x i1> @sge_t(<2 x i1> %a) {
ret <2 x i1> %r
}
define <2 x i1> @sge_t_undef_elt(<2 x i1> %a) {
; CHECK-LABEL: @sge_t_undef_elt(
; CHECK-NEXT: [[R:%.*]] = icmp sge <2 x i1> [[A:%.*]], <i1 true, i1 undef>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%r = icmp sge <2 x i1> %a, <i1 true, i1 undef>
ret <2 x i1> %r
}
define <2 x i1> @sge_f(<2 x i1> %a) {
; CHECK-LABEL: @sge_f(
; CHECK-NEXT: [[R:%.*]] = icmp sge <2 x i1> %a, zeroinitializer