blob: 2473ec1403f598faac647b58d8541bd812a43399 [file] [log] [blame]
Reid Spencerea8b07e2007-03-23 20:48:34 +00001; This test makes sure that add instructions are properly eliminated.
2; This test is for Integer BitWidth <= 64 && BitWidth % 8 != 0.
3
4; RUN: llvm-as < %s | opt -instcombine -disable-output &&
5; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
6; RUN: grep -v OK | not grep add
7
8implementation
9
10define i1 @test1(i1 %x) {
11 %tmp.2 = xor i1 %x, 1
12 ;; Add of sign bit -> xor of sign bit.
13 %tmp.4 = add i1 %tmp.2, 1
14 ret i1 %tmp.4
15}
16
17define i47 @test2(i47 %x) {
18 %tmp.2 = xor i47 %x, 70368744177664
19 ;; Add of sign bit -> xor of sign bit.
20 %tmp.4 = add i47 %tmp.2, 70368744177664
21 ret i47 %tmp.4
22}
23
24define i15 @test3(i15 %x) {
25 %tmp.2 = xor i15 %x, 16384
26 ;; Add of sign bit -> xor of sign bit.
27 %tmp.4 = add i15 %tmp.2, 16384
28 ret i15 %tmp.4
29}
30
31define i12 @test4(i12 %x) {
32 ;; If we have ADD(XOR(AND(X, 0xFF), 0xF..F80), 0x80), it's a sext.
33 %X = and i12 %x, 63
34 %tmp.2 = xor i12 %X, 4064 ; 0xFE0
35 %tmp.4 = add i12 %tmp.2, 32 ; 0x020
36 ret i12 %tmp.4
37}
38
39define i49 @test5(i49 %x) {
40 ;; If we have ADD(XOR(AND(X, 0xFF), 0x80), 0xF..F80), it's a sext.
41 %X = and i49 %x, 16777215 ; 0x0000000ffffff
42 %tmp.2 = xor i49 %X, 8388608 ; 0x0000000800000
43 %tmp.4 = add i49 %tmp.2, -8388608 ; 0x1FFFFFF800000
44 ret i49 %tmp.4
45}
46
47define i49 @test6(i49 %x) {
48 ;; (x & 254)+1 -> (x & 254)|1
49 %tmp.2 = and i49 %x, 562949953421310
50 %tmp.4 = add i49 %tmp.2, 1
51 ret i49 %tmp.4
52}