xref: /llvm-project/llvm/test/Transforms/InstCombine/icmp-signmask.ll (revision 38fffa630ee80163dc65e759392ad29798905679)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3
4define i1 @cmp_x_and_negp2_with_eq(i8 %x) {
5; CHECK-LABEL: @cmp_x_and_negp2_with_eq(
6; CHECK-NEXT:    [[R:%.*]] = icmp slt i8 [[X:%.*]], -126
7; CHECK-NEXT:    ret i1 [[R]]
8;
9  %andx = and i8 %x, -2
10  %r = icmp eq i8 %andx, 128
11  ret i1 %r
12}
13
14define i1 @cmp_x_and_negp2_with_eq_fail_not_signmask(i8 %x) {
15; CHECK-LABEL: @cmp_x_and_negp2_with_eq_fail_not_signmask(
16; CHECK-NEXT:    [[ANDX:%.*]] = and i8 [[X:%.*]], -2
17; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[ANDX]], -124
18; CHECK-NEXT:    ret i1 [[R]]
19;
20  %andx = and i8 %x, -2
21  %r = icmp eq i8 %andx, 132
22  ret i1 %r
23}
24
25define <2 x i1> @cmp_x_and_negp2_with_ne(<2 x i8> %x) {
26; CHECK-LABEL: @cmp_x_and_negp2_with_ne(
27; CHECK-NEXT:    [[R:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 -121, i8 -113>
28; CHECK-NEXT:    ret <2 x i1> [[R]]
29;
30  %andx = and <2 x i8> %x, <i8 -8, i8 -16>
31  %r = icmp ne <2 x i8> %andx, <i8 128, i8 128>
32  ret <2 x i1> %r
33}
34
35define <2 x i1> @cmp_x_and_negp2_with_ne_or_z(<2 x i8> %x) {
36; CHECK-LABEL: @cmp_x_and_negp2_with_ne_or_z(
37; CHECK-NEXT:    [[R:%.*]] = icmp sge <2 x i8> [[X:%.*]], <i8 -128, i8 -112>
38; CHECK-NEXT:    ret <2 x i1> [[R]]
39;
40  %andx = and <2 x i8> %x, <i8 0, i8 -16>
41  %r = icmp ne <2 x i8> %andx, <i8 128, i8 128>
42  ret <2 x i1> %r
43}
44
45define <2 x i1> @cmp_x_and_negp2_with_ne_fail_not_p2(<2 x i8> %x) {
46; CHECK-LABEL: @cmp_x_and_negp2_with_ne_fail_not_p2(
47; CHECK-NEXT:    [[ANDX:%.*]] = and <2 x i8> [[X:%.*]], <i8 -8, i8 -15>
48; CHECK-NEXT:    [[R:%.*]] = icmp ne <2 x i8> [[ANDX]], splat (i8 -128)
49; CHECK-NEXT:    ret <2 x i1> [[R]]
50;
51  %andx = and <2 x i8> %x, <i8 -8, i8 -15>
52  %r = icmp ne <2 x i8> %andx, <i8 128, i8 128>
53  ret <2 x i1> %r
54}
55