]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/InstCombine/zext.ll
Vendor import of llvm release_39 branch r276489:
[FreeBSD/FreeBSD.git] / test / Transforms / InstCombine / zext.ll
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
3
4 define i64 @test_sext_zext(i16 %A) {
5 ; CHECK-LABEL: @test_sext_zext(
6 ; CHECK-NEXT:    [[C2:%.*]] = zext i16 %A to i64
7 ; CHECK-NEXT:    ret i64 [[C2]]
8 ;
9   %c1 = zext i16 %A to i32
10   %c2 = sext i32 %c1 to i64
11   ret i64 %c2
12 }
13
14 define <2 x i64> @test2(<2 x i1> %A) {
15 ; CHECK-LABEL: @test2(
16 ; CHECK-NEXT:    [[TMP1:%.*]] = zext <2 x i1> %A to <2 x i64>
17 ; CHECK-NEXT:    [[ZEXT:%.*]] = xor <2 x i64> [[TMP1]], <i64 1, i64 1>
18 ; CHECK-NEXT:    ret <2 x i64> [[ZEXT]]
19 ;
20   %xor = xor <2 x i1> %A, <i1 true, i1 true>
21   %zext = zext <2 x i1> %xor to <2 x i64>
22   ret <2 x i64> %zext
23 }
24
25 define <2 x i64> @test3(<2 x i64> %A) {
26 ; CHECK-LABEL: @test3(
27 ; CHECK-NEXT:    [[AND:%.*]] = and <2 x i64> %A, <i64 23, i64 42>
28 ; CHECK-NEXT:    ret <2 x i64> [[AND]]
29 ;
30   %trunc = trunc <2 x i64> %A to <2 x i32>
31   %and = and <2 x i32> %trunc, <i32 23, i32 42>
32   %zext = zext <2 x i32> %and to <2 x i64>
33   ret <2 x i64> %zext
34 }
35
36 define <2 x i64> @test4(<2 x i64> %A) {
37 ; CHECK-LABEL: @test4(
38 ; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i64> %A, <i64 4294967295, i64 4294967295>
39 ; CHECK-NEXT:    [[XOR:%.*]] = and <2 x i64> [[TMP1]], <i64 23, i64 42>
40 ; CHECK-NEXT:    ret <2 x i64> [[XOR]]
41 ;
42   %trunc = trunc <2 x i64> %A to <2 x i32>
43   %and = and <2 x i32> %trunc, <i32 23, i32 42>
44   %xor = xor <2 x i32> %and, <i32 23, i32 42>
45   %zext = zext <2 x i32> %xor to <2 x i64>
46   ret <2 x i64> %zext
47 }
48
49 ; FIXME: If the xor was done in the smaller type, the back-to-back zexts would get combined.
50
51 define i64 @fold_xor_zext_sandwich(i1 %a) {
52 ; CHECK-LABEL: @fold_xor_zext_sandwich(
53 ; CHECK-NEXT:    [[ZEXT1:%.*]] = zext i1 %a to i32
54 ; CHECK-NEXT:    [[XOR:%.*]] = xor i32 [[ZEXT1]], 1
55 ; CHECK-NEXT:    [[ZEXT2:%.*]] = zext i32 [[XOR]] to i64
56 ; CHECK-NEXT:    ret i64 [[ZEXT2]]
57 ;
58   %zext1 = zext i1 %a to i32
59   %xor = xor i32 %zext1, 1
60   %zext2 = zext i32 %xor to i64
61   ret i64 %zext2
62 }
63
64 define <2 x i64> @fold_xor_zext_sandwich_vec(<2 x i1> %a) {
65 ; CHECK-LABEL: @fold_xor_zext_sandwich_vec(
66 ; CHECK-NEXT:    [[ZEXT1:%.*]] = zext <2 x i1> %a to <2 x i64>
67 ; CHECK-NEXT:    [[XOR:%.*]] = xor <2 x i64> [[ZEXT1]], <i64 1, i64 1>
68 ; CHECK-NEXT:    ret <2 x i64> [[XOR]]
69 ;
70   %zext1 = zext <2 x i1> %a to <2 x i32>
71   %xor = xor <2 x i32> %zext1, <i32 1, i32 1>
72   %zext2 = zext <2 x i32> %xor to <2 x i64>
73   ret <2 x i64> %zext2
74 }
75