[SLP] Add cost model for `llvm.powi.*` intrinsics
[llvm-project.git] / llvm / test / Transforms / InstCombine / apint-and.ll
blob793b25e548280c5336bf4372ce7aeaae8bf8a640
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 ; FIXME: Some of these tests belong in InstSimplify.
6 ; Integer BitWidth <= 64 && BitWidth % 8 != 0.
8 define i39 @test0(i39 %A) {
9 ; CHECK-LABEL: @test0(
10 ; CHECK-NEXT:    ret i39 0
12   %B = and i39 %A, 0 ; zero result
13   ret i39 %B
16 define i15 @test2(i15 %x) {
17 ; CHECK-LABEL: @test2(
18 ; CHECK-NEXT:    ret i15 [[X:%.*]]
20   %tmp.2 = and i15 %x, -1 ; noop
21   ret i15 %tmp.2
24 define i23 @test3(i23 %x) {
25 ; CHECK-LABEL: @test3(
26 ; CHECK-NEXT:    ret i23 0
28   %tmp.0 = and i23 %x, 127
29   %tmp.2 = and i23 %tmp.0, 128
30   ret i23 %tmp.2
33 define i1 @test4(i37 %x) {
34 ; CHECK-LABEL: @test4(
35 ; CHECK-NEXT:    [[B:%.*]] = icmp ugt i37 [[X:%.*]], 2147483647
36 ; CHECK-NEXT:    ret i1 [[B]]
38   %A = and i37 %x, -2147483648
39   %B = icmp ne i37 %A, 0
40   ret i1 %B
43 define i7 @test5(i7 %A, i7* %P) {
44 ; CHECK-LABEL: @test5(
45 ; CHECK-NEXT:    [[TMP1:%.*]] = and i7 [[A:%.*]], -4
46 ; CHECK-NEXT:    [[C:%.*]] = xor i7 [[TMP1]], 15
47 ; CHECK-NEXT:    store i7 [[C]], i7* [[P:%.*]], align 1
48 ; CHECK-NEXT:    ret i7 3
50   %B = or i7 %A, 3
51   %C = xor i7 %B, 12
52   store i7 %C, i7* %P
53   %r = and i7 %C, 3
54   ret i7 %r
57 define i47 @test7(i47 %A) {
58 ; CHECK-LABEL: @test7(
59 ; CHECK-NEXT:    [[TMP1:%.*]] = lshr i47 [[A:%.*]], 39
60 ; CHECK-NEXT:    ret i47 [[TMP1]]
62   %X = ashr i47 %A, 39 ;; sign extend
63   %C1 = and i47 %X, 255
64   ret i47 %C1
67 ; Integer BitWidth > 64 && BitWidth <= 1024.
69 define i999 @test8(i999 %A) {
70 ; CHECK-LABEL: @test8(
71 ; CHECK-NEXT:    ret i999 0
73   %B = and i999 %A, 0 ; zero result
74   ret i999 %B
77 define i1005 @test9(i1005 %x) {
78 ; CHECK-LABEL: @test9(
79 ; CHECK-NEXT:    ret i1005 [[X:%.*]]
81   %tmp.2 = and i1005 %x, -1 ; noop
82   ret i1005 %tmp.2
85 define i123 @test10(i123 %x) {
86 ; CHECK-LABEL: @test10(
87 ; CHECK-NEXT:    ret i123 0
89   %tmp.0 = and i123 %x, 127
90   %tmp.2 = and i123 %tmp.0, 128
91   ret i123 %tmp.2
94 define i1 @test11(i737 %x) {
95 ; CHECK-LABEL: @test11(
96 ; CHECK-NEXT:    [[B:%.*]] = icmp ugt i737 [[X:%.*]], 2147483647
97 ; CHECK-NEXT:    ret i1 [[B]]
99   %A = and i737 %x, -2147483648
100   %B = icmp ne i737 %A, 0
101   ret i1 %B
104 define i117 @test12(i117 %A, i117* %P) {
105 ; CHECK-LABEL: @test12(
106 ; CHECK-NEXT:    [[TMP1:%.*]] = and i117 [[A:%.*]], -4
107 ; CHECK-NEXT:    [[C:%.*]] = xor i117 [[TMP1]], 15
108 ; CHECK-NEXT:    store i117 [[C]], i117* [[P:%.*]], align 4
109 ; CHECK-NEXT:    ret i117 3
111   %B = or i117 %A, 3
112   %C = xor i117 %B, 12
113   store i117 %C, i117* %P
114   %r = and i117 %C, 3
115   ret i117 %r
118 define i1024 @test13(i1024 %A) {
119 ; CHECK-LABEL: @test13(
120 ; CHECK-NEXT:    [[TMP1:%.*]] = lshr i1024 [[A:%.*]], 1016
121 ; CHECK-NEXT:    ret i1024 [[TMP1]]
123   %X = ashr i1024 %A, 1016 ;; sign extend
124   %C1 = and i1024 %X, 255
125   ret i1024 %C1