blob: 1f3285af65cc103e1759e0124bd8cb8eeee0e281 [file] [log] [blame]
Philip Reames675418e2015-10-06 20:20:45 +00001; RUN: opt < %s -S -instcombine | FileCheck %s
2; Note: This is testing functionality in computeKnownBits. I'd have rather
3; used instsimplify, but the bit test folding is apparently only in instcombine.
4
5declare i16 @llvm.bswap.i16(i16)
6declare i32 @llvm.bswap.i32(i32)
7
8define i1 @test1(i16 %arg) {
9; CHECK-LABEL: @test1
10; CHECK: ret i1 true
11 %a = or i16 %arg, 511
12 %b = call i16 @llvm.bswap.i16(i16 %a)
13 %and = and i16 %b, 256
14 %res = icmp eq i16 %and, 256
15 ret i1 %res
16}
17
18define i1 @test2(i16 %arg) {
19; CHECK-LABEL: @test2
20; CHECK: ret i1 true
21 %a = or i16 %arg, 1
22 %b = call i16 @llvm.bswap.i16(i16 %a)
23 %and = and i16 %b, 256
24 %res = icmp eq i16 %and, 256
25 ret i1 %res
26}
27
28
29define i1 @test3(i16 %arg) {
30; CHECK-LABEL: @test3
31; CHECK: ret i1 true
32 %a = or i16 %arg, 256
33 %b = call i16 @llvm.bswap.i16(i16 %a)
34 %and = and i16 %b, 1
35 %res = icmp eq i16 %and, 1
36 ret i1 %res
37}
38
39define i1 @test4(i32 %arg) {
40; CHECK-LABEL: @test4
41; CHECK: ret i1 true
42 %a = or i32 %arg, 2147483647 ; i32_MAX
43 %b = call i32 @llvm.bswap.i32(i32 %a)
44 %and = and i32 %b, 127
45 %res = icmp eq i32 %and, 127
46 ret i1 %res
47}