1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 ; FIXME: Some of these tests belong in InstSimplify.
5 ; Integer BitWidth <= 64 && BitWidth % 8 != 0.
7 define i39 @test0(i39 %A) {
9 ; CHECK-NEXT: ret i39 0
11 %B = and i39 %A, 0 ; zero result
15 define i15 @test2(i15 %x) {
16 ; CHECK-LABEL: @test2(
17 ; CHECK-NEXT: ret i15 %x
19 %tmp.2 = and i15 %x, -1 ; noop
23 define i23 @test3(i23 %x) {
24 ; CHECK-LABEL: @test3(
25 ; CHECK-NEXT: ret i23 0
27 %tmp.0 = and i23 %x, 127
28 %tmp.2 = and i23 %tmp.0, 128
32 define i1 @test4(i37 %x) {
33 ; CHECK-LABEL: @test4(
34 ; CHECK-NEXT: [[B:%.*]] = icmp ugt i37 %x, 2147483647
35 ; CHECK-NEXT: ret i1 [[B]]
37 %A = and i37 %x, -2147483648
38 %B = icmp ne i37 %A, 0
42 define i7 @test5(i7 %A, i7* %P) {
43 ; CHECK-LABEL: @test5(
44 ; CHECK-NEXT: [[B:%.*]] = or i7 %A, 3
45 ; CHECK-NEXT: [[C:%.*]] = xor i7 [[B]], 12
46 ; CHECK-NEXT: store i7 [[C]], i7* %P, align 1
47 ; CHECK-NEXT: ret i7 3
56 define i47 @test7(i47 %A) {
57 ; CHECK-LABEL: @test7(
58 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i47 %A, 39
59 ; CHECK-NEXT: ret i47 [[TMP1]]
61 %X = ashr i47 %A, 39 ;; sign extend
66 ; Integer BitWidth > 64 && BitWidth <= 1024.
68 define i999 @test8(i999 %A) {
69 ; CHECK-LABEL: @test8(
70 ; CHECK-NEXT: ret i999 0
72 %B = and i999 %A, 0 ; zero result
76 define i1005 @test9(i1005 %x) {
77 ; CHECK-LABEL: @test9(
78 ; CHECK-NEXT: ret i1005 %x
80 %tmp.2 = and i1005 %x, -1 ; noop
84 define i123 @test10(i123 %x) {
85 ; CHECK-LABEL: @test10(
86 ; CHECK-NEXT: ret i123 0
88 %tmp.0 = and i123 %x, 127
89 %tmp.2 = and i123 %tmp.0, 128
93 define i1 @test11(i737 %x) {
94 ; CHECK-LABEL: @test11(
95 ; CHECK-NEXT: [[B:%.*]] = icmp ugt i737 %x, 2147483647
96 ; CHECK-NEXT: ret i1 [[B]]
98 %A = and i737 %x, -2147483648
99 %B = icmp ne i737 %A, 0
103 define i117 @test12(i117 %A, i117* %P) {
104 ; CHECK-LABEL: @test12(
105 ; CHECK-NEXT: [[B:%.*]] = or i117 %A, 3
106 ; CHECK-NEXT: [[C:%.*]] = xor i117 [[B]], 12
107 ; CHECK-NEXT: store i117 [[C]], i117* %P, align 4
108 ; CHECK-NEXT: ret i117 3
112 store i117 %C, i117* %P
117 define i1024 @test13(i1024 %A) {
118 ; CHECK-LABEL: @test13(
119 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i1024 %A, 1016
120 ; CHECK-NEXT: ret i1024 [[TMP1]]
122 %X = ashr i1024 %A, 1016 ;; sign extend
123 %C1 = and i1024 %X, 255