• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
2
3define zeroext i1 @f1(i8* %x) {
4; CHECK-LABEL: f1:
5; CHECK: movb	(%rdi), %al
6; CHECK-NEXT: ret
7
8entry:
9  %0 = load i8, i8* %x, align 1, !range !0
10  %tobool = trunc i8 %0 to i1
11  ret i1 %tobool
12}
13
14define zeroext i1 @f2(i8* %x) {
15; CHECK-LABEL: f2:
16; CHECK: movb	(%rdi), %al
17; CHECK-NEXT: ret
18
19entry:
20  %0 = load i8, i8* %x, align 1, !range !0
21  %tobool = icmp ne i8 %0, 0
22  ret i1 %tobool
23}
24
25!0 = !{i8 0, i8 2}
26
27
28; check that we don't build a "trunc" from i1 to i1, which would assert.
29define zeroext i1 @f3(i1 %x) {
30; CHECK-LABEL: f3:
31
32entry:
33  %tobool = icmp ne i1 %x, 0
34  ret i1 %tobool
35}
36
37; check that we don't build a trunc when other bits are needed
38define zeroext i1 @f4(i32 %x) {
39; CHECK-LABEL: f4:
40; CHECK: and
41
42entry:
43  %y = and i32 %x, 32768
44  %z = icmp ne i32 %y, 0
45  ret i1 %z
46}
47