tstbit.ll
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=hexagon < %s | FileCheck %s
; Function Attrs: nounwind readnone
define i32 @f0(i32 %a0, i32 %a1) #0 {
; CHECK-LABEL: f0:
; CHECK: // %bb.0: // %b0
; CHECK-NEXT: {
; CHECK-NEXT: p0 = tstbit(r0,r1)
; CHECK-NEXT: }
; CHECK-NEXT: {
; CHECK-NEXT: r0 = mux(p0,#1,#0)
; CHECK-NEXT: jumpr r31
; CHECK-NEXT: }
b0:
%v0 = shl i32 1, %a1
%v1 = and i32 %v0, %a0
%v2 = icmp ne i32 %v1, 0
%v3 = zext i1 %v2 to i32
ret i32 %v3
}
define i64 @is_upper_bit_clear_i64(i64 %x) #0 {
; CHECK-LABEL: is_upper_bit_clear_i64:
; CHECK: // %bb.0:
; CHECK-NEXT: {
; CHECK-NEXT: p0 = !tstbit(r1,#5)
; CHECK-NEXT: r1 = #0
; CHECK-NEXT: }
; CHECK-NEXT: {
; CHECK-NEXT: r0 = mux(p0,#1,#0)
; CHECK-NEXT: jumpr r31
; CHECK-NEXT: }
%sh = lshr i64 %x, 37
%m = and i64 %sh, 1
%r = xor i64 %m, 1
ret i64 %r
}
define i64 @is_lower_bit_clear_i64(i64 %x) #0 {
; CHECK-LABEL: is_lower_bit_clear_i64:
; CHECK: // %bb.0:
; CHECK-NEXT: {
; CHECK-NEXT: p0 = !tstbit(r0,#27)
; CHECK-NEXT: r1 = #0
; CHECK-NEXT: }
; CHECK-NEXT: {
; CHECK-NEXT: r0 = mux(p0,#1,#0)
; CHECK-NEXT: jumpr r31
; CHECK-NEXT: }
%sh = lshr i64 %x, 27
%m = and i64 %sh, 1
%r = xor i64 %m, 1
ret i64 %r
}
define i32 @is_bit_clear_i32(i32 %x) #0 {
; CHECK-LABEL: is_bit_clear_i32:
; CHECK: // %bb.0:
; CHECK-NEXT: {
; CHECK-NEXT: p0 = !tstbit(r0,#27)
; CHECK-NEXT: }
; CHECK-NEXT: {
; CHECK-NEXT: r0 = mux(p0,#1,#0)
; CHECK-NEXT: jumpr r31
; CHECK-NEXT: }
%sh = lshr i32 %x, 27
%n = xor i32 %sh, -1
%r = and i32 %n, 1
ret i32 %r
}
define i16 @is_bit_clear_i16(i16 %x) #0 {
; CHECK-LABEL: is_bit_clear_i16:
; CHECK: // %bb.0:
; CHECK-NEXT: {
; CHECK-NEXT: p0 = !tstbit(r0,#7)
; CHECK-NEXT: }
; CHECK-NEXT: {
; CHECK-NEXT: r0 = mux(p0,#1,#0)
; CHECK-NEXT: jumpr r31
; CHECK-NEXT: }
%sh = lshr i16 %x, 7
%m = and i16 %sh, 1
%r = xor i16 %m, 1
ret i16 %r
}
define i8 @is_bit_clear_i8(i8 %x) #0 {
; CHECK-LABEL: is_bit_clear_i8:
; CHECK: // %bb.0:
; CHECK-NEXT: {
; CHECK-NEXT: p0 = !tstbit(r0,#3)
; CHECK-NEXT: }
; CHECK-NEXT: {
; CHECK-NEXT: r0 = mux(p0,#1,#0)
; CHECK-NEXT: jumpr r31
; CHECK-NEXT: }
%sh = lshr i8 %x, 3
%m = and i8 %sh, 1
%r = xor i8 %m, 1
ret i8 %r
}
attributes #0 = { nounwind readnone }