1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 define <2 x i1> @icmp_eq_zext_is_false(<2 x i8> %x) {
5 ; CHECK-LABEL: @icmp_eq_zext_is_false(
6 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
8 %xext = zext <2 x i8> %x to <2 x i32>
9 %cmp = icmp eq <2 x i32> %xext, <i32 511, i32 1234>
13 define <2 x i1> @icmp_ugt_zext_is_false(<2 x i8> %x) {
14 ; CHECK-LABEL: @icmp_ugt_zext_is_false(
15 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
17 %xext = zext <2 x i8> %x to <2 x i32>
18 %cmp = icmp ugt <2 x i32> %xext, <i32 256, i32 1234>
22 define <2 x i1> @icmp_ugt_zext_todo_off_by1(<2 x i8> %x) {
23 ; CHECK-LABEL: @icmp_ugt_zext_todo_off_by1(
24 ; CHECK-NEXT: [[XEXT:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
25 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt <2 x i32> [[XEXT]], <i32 1234, i32 255>
26 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
28 %xext = zext <2 x i8> %x to <2 x i32>
29 %cmp = icmp ugt <2 x i32> %xext, <i32 1234, i32 255>
33 define <2 x i1> @icmp_uge_zext_is_false(<2 x i8> %x) {
34 ; CHECK-LABEL: @icmp_uge_zext_is_false(
35 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
37 %xext = zext <2 x i8> %x to <2 x i32>
38 %cmp = icmp uge <2 x i32> %xext, <i32 256, i32 1234>
42 define <2 x i1> @icmp_eq_zext_fail(<2 x i8> %x) {
43 ; CHECK-LABEL: @icmp_eq_zext_fail(
44 ; CHECK-NEXT: [[XEXT:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
45 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[XEXT]], <i32 511, i32 123>
46 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
48 %xext = zext <2 x i8> %x to <2 x i32>
49 %cmp = icmp eq <2 x i32> %xext, <i32 511, i32 123>
53 define <2 x i1> @icmp_eq_zext_unused(<2 x i8> %x) {
54 ; CHECK-LABEL: @icmp_eq_zext_unused(
55 ; CHECK-NEXT: [[XEXT:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
56 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[XEXT]], <i32 254, i32 123>
57 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
59 %xext = zext <2 x i8> %x to <2 x i32>
60 %cmp = icmp eq <2 x i32> %xext, <i32 254, i32 123>
64 define <2 x i1> @icmp_ne_zext_is_true(<2 x i8> %x) {
65 ; CHECK-LABEL: @icmp_ne_zext_is_true(
66 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
68 %xext = zext <2 x i8> %x to <2 x i32>
69 %cmp = icmp ne <2 x i32> %xext, <i32 256, i32 1234>
73 define <2 x i1> @icmp_ult_zext_is_true(<2 x i8> %x) {
74 ; CHECK-LABEL: @icmp_ult_zext_is_true(
75 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
77 %xext = zext <2 x i8> %x to <2 x i32>
78 %cmp = icmp ult <2 x i32> %xext, <i32 256, i32 1234>
82 define <2 x i1> @icmp_ule_zext_is_true(<2 x i8> %x) {
83 ; CHECK-LABEL: @icmp_ule_zext_is_true(
84 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
86 %xext = zext <2 x i8> %x to <2 x i32>
87 %cmp = icmp ule <2 x i32> %xext, <i32 256, i32 -1>
91 define <2 x i1> @icmp_ne_zext_fail(<2 x i8> %x) {
92 ; CHECK-LABEL: @icmp_ne_zext_fail(
93 ; CHECK-NEXT: [[XEXT:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
94 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[XEXT]], <i32 256, i32 123>
95 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
97 %xext = zext <2 x i8> %x to <2 x i32>
98 %cmp = icmp ne <2 x i32> %xext, <i32 256, i32 123>
102 define <2 x i1> @icmp_ne_zext_unused(<2 x i8> %x) {
103 ; CHECK-LABEL: @icmp_ne_zext_unused(
104 ; CHECK-NEXT: [[XEXT:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
105 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[XEXT]], <i32 1, i32 123>
106 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
108 %xext = zext <2 x i8> %x to <2 x i32>
109 %cmp = icmp ne <2 x i32> %xext, <i32 1, i32 123>
113 define <2 x i1> @icmp_sge_zext_is_false_true(<2 x i8> %x) {
114 ; CHECK-LABEL: @icmp_sge_zext_is_false_true(
115 ; CHECK-NEXT: ret <2 x i1> <i1 false, i1 true>
117 %xext = zext <2 x i8> %x to <2 x i32>
118 %cmp = icmp sge <2 x i32> %xext, <i32 257, i32 -450>
122 define <2 x i1> @icmp_sle_zext_is_false_false(<2 x i8> %x) {
123 ; CHECK-LABEL: @icmp_sle_zext_is_false_false(
124 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
126 %xext = zext <2 x i8> %x to <2 x i32>
127 %cmp = icmp sle <2 x i32> %xext, <i32 -256, i32 -450>
131 define <2 x i1> @icmp_eq_sext_is_false(<2 x i8> %x) {
132 ; CHECK-LABEL: @icmp_eq_sext_is_false(
133 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
135 %xext = sext <2 x i8> %x to <2 x i32>
136 %cmp = icmp eq <2 x i32> %xext, <i32 255, i32 129>
140 define <2 x i1> @icmp_eq_sext_fail(<2 x i8> %x) {
141 ; CHECK-LABEL: @icmp_eq_sext_fail(
142 ; CHECK-NEXT: [[XEXT:%.*]] = sext <2 x i8> [[X:%.*]] to <2 x i32>
143 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[XEXT]], <i32 255, i32 -1>
144 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
146 %xext = sext <2 x i8> %x to <2 x i32>
147 %cmp = icmp eq <2 x i32> %xext, <i32 255, i32 -1>
151 define <2 x i1> @icmp_ne_sext_is_true(<2 x i8> %x) {
152 ; CHECK-LABEL: @icmp_ne_sext_is_true(
153 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
155 %xext = sext <2 x i8> %x to <2 x i32>
156 %cmp = icmp ne <2 x i32> %xext, <i32 199, i32 1234>
160 define <2 x i1> @icmp_sgt_sext_is_true_false(<2 x i8> %x) {
161 ; CHECK-LABEL: @icmp_sgt_sext_is_true_false(
162 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 false>
164 %xext = sext <2 x i8> %x to <2 x i32>
165 %cmp = icmp sgt <2 x i32> %xext, <i32 -250, i32 450>
169 define <2 x i1> @icmp_slt_sext_is_true_false(<2 x i8> %x) {
170 ; CHECK-LABEL: @icmp_slt_sext_is_true_false(
171 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 false>
173 %xext = sext <2 x i8> %x to <2 x i32>
174 %cmp = icmp slt <2 x i32> %xext, <i32 257, i32 -450>