1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instsimplify -S -o - | FileCheck %s
3
4; When both operands are undef in a lane, that lane should produce an undef result.
5
6define <3 x i8> @shl() {
7; CHECK-LABEL: @shl(
8; CHECK-NEXT:    ret <3 x i8> <i8 poison, i8 0, i8 0>
9;
10  %c = shl <3 x i8> undef, <i8 undef, i8 4, i8 1>
11  ret <3 x i8> %c
12}
13
14define <3 x i8> @and() {
15; CHECK-LABEL: @and(
16; CHECK-NEXT:    ret <3 x i8> <i8 undef, i8 0, i8 undef>
17;
18  %c = and <3 x i8> <i8 undef, i8 42, i8 undef>, undef
19  ret <3 x i8> %c
20}
21
22define <3 x i8> @and_commute() {
23; CHECK-LABEL: @and_commute(
24; CHECK-NEXT:    ret <3 x i8> <i8 0, i8 0, i8 undef>
25;
26  %c = and <3 x i8> undef, <i8 -42, i8 42, i8 undef>
27  ret <3 x i8> %c
28}
29
30define <3 x i8> @or() {
31; CHECK-LABEL: @or(
32; CHECK-NEXT:    ret <3 x i8> <i8 undef, i8 -1, i8 undef>
33;
34  %c = or <3 x i8> <i8 undef, i8 42, i8 undef>, undef
35  ret <3 x i8> %c
36}
37
38define <3 x i8> @or_commute() {
39; CHECK-LABEL: @or_commute(
40; CHECK-NEXT:    ret <3 x i8> <i8 -1, i8 -1, i8 undef>
41;
42  %c = or <3 x i8> undef, <i8 -42, i8 42, i8 undef>
43  ret <3 x i8> %c
44}
45
46define <3 x float> @fadd() {
47; CHECK-LABEL: @fadd(
48; CHECK-NEXT:    ret <3 x float> <float undef, float 0x7FF8000000000000, float undef>
49;
50  %c = fadd <3 x float> <float undef, float 42.0, float undef>, undef
51  ret <3 x float> %c
52}
53
54define <3 x float> @fadd_commute() {
55; CHECK-LABEL: @fadd_commute(
56; CHECK-NEXT:    ret <3 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float undef>
57;
58  %c = fadd <3 x float> undef, <float -42.0, float 42.0, float undef>
59  ret <3 x float> %c
60}
61
62define <4 x i32> @shuffle_of_undefs(<4 x i32> %v1, <4 x i32> %v2) {
63; CHECK-LABEL: @shuffle_of_undefs(
64; CHECK-NEXT:    ret <4 x i32> undef
65;
66  %r = shufflevector <4 x i32> undef, <4 x i32> undef, <4 x i32> <i32 5, i32 1, i32 2, i32 3>
67  ret <4 x i32> %r
68}
69
70