1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s 3 4 define zeroext i1 @f1(i8* %x) { 5 ; CHECK-LABEL: f1: 6 ; CHECK: ## %bb.0: ## %entry 7 ; CHECK-NEXT: movb (%rdi), %al 8 ; CHECK-NEXT: retq 9 10 entry: 11 %0 = load i8, i8* %x, align 1, !range !0 12 %tobool = trunc i8 %0 to i1 13 ret i1 %tobool 14 } 15 16 define zeroext i1 @f2(i8* %x) { 17 ; CHECK-LABEL: f2: 18 ; CHECK: ## %bb.0: ## %entry 19 ; CHECK-NEXT: movb (%rdi), %al 20 ; CHECK-NEXT: retq 21 22 entry: 23 %0 = load i8, i8* %x, align 1, !range !0 24 %tobool = icmp ne i8 %0, 0 25 ret i1 %tobool 26 } 27 28 !0 = !{i8 0, i8 2} 29 30 31 ; check that we don't build a "trunc" from i1 to i1, which would assert. 32 define zeroext i1 @f3(i1 %x) { 33 ; CHECK-LABEL: f3: 34 ; CHECK: ## %bb.0: ## %entry 35 ; CHECK-NEXT: andb $1, %dil 36 ; CHECK-NEXT: movl %edi, %eax 37 ; CHECK-NEXT: retq 38 39 entry: 40 %tobool = icmp ne i1 %x, 0 41 ret i1 %tobool 42 } 43 44 ; check that we don't build a trunc when other bits are needed 45 define zeroext i1 @f4(i32 %x) { 46 ; CHECK-LABEL: f4: 47 ; CHECK: ## %bb.0: ## %entry 48 ; CHECK-NEXT: movzwl %di, %eax 49 ; CHECK-NEXT: shrl $15, %eax 50 ; CHECK-NEXT: ## kill: def $al killed $al killed $eax 51 ; CHECK-NEXT: retq 52 53 entry: 54 %y = and i32 %x, 32768 55 %z = icmp ne i32 %y, 0 56 ret i1 %z 57 } 58