2007-01-13 05:06:52 +00:00
|
|
|
; An integer truncation to i1 should be done with an and instruction to make
|
2006-11-27 01:05:10 +00:00
|
|
|
; sure only the LSBit survives. Test that this is the case both for a returned
|
|
|
|
; value and as the operand of a branch.
|
2009-11-22 11:45:44 +00:00
|
|
|
; RUN: llc < %s -march=x86 | FileCheck %s
|
2006-12-31 06:02:00 +00:00
|
|
|
|
2011-06-17 03:14:27 +00:00
|
|
|
define zeroext i1 @test1(i32 %X) nounwind {
|
2007-01-13 05:06:52 +00:00
|
|
|
%Y = trunc i32 %X to i1
|
|
|
|
ret i1 %Y
|
2006-11-27 01:05:10 +00:00
|
|
|
}
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test1:
|
2009-11-22 11:45:44 +00:00
|
|
|
; CHECK: andl $1, %eax
|
2006-11-27 01:05:10 +00:00
|
|
|
|
2010-02-27 07:36:59 +00:00
|
|
|
define i1 @test2(i32 %val, i32 %mask) nounwind {
|
2006-11-27 01:05:10 +00:00
|
|
|
entry:
|
2007-02-02 02:16:23 +00:00
|
|
|
%shifted = ashr i32 %val, %mask
|
2006-12-31 06:02:00 +00:00
|
|
|
%anded = and i32 %shifted, 1
|
2007-01-13 05:06:52 +00:00
|
|
|
%trunced = trunc i32 %anded to i1
|
|
|
|
br i1 %trunced, label %ret_true, label %ret_false
|
2006-11-27 01:05:10 +00:00
|
|
|
ret_true:
|
2007-01-13 05:06:52 +00:00
|
|
|
ret i1 true
|
2006-11-27 01:05:10 +00:00
|
|
|
ret_false:
|
2007-01-13 05:06:52 +00:00
|
|
|
ret i1 false
|
2006-11-27 01:05:10 +00:00
|
|
|
}
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test2:
|
2013-10-15 23:33:07 +00:00
|
|
|
; CHECK: btl
|
2006-11-27 01:05:10 +00:00
|
|
|
|
2010-02-27 07:36:59 +00:00
|
|
|
define i32 @test3(i8* %ptr) nounwind {
|
2006-12-31 06:02:00 +00:00
|
|
|
%val = load i8* %ptr
|
2007-01-13 05:06:52 +00:00
|
|
|
%tmp = trunc i8 %val to i1
|
|
|
|
br i1 %tmp, label %cond_true, label %cond_false
|
2006-11-27 01:05:10 +00:00
|
|
|
cond_true:
|
2006-12-31 06:02:00 +00:00
|
|
|
ret i32 21
|
2006-11-27 01:05:10 +00:00
|
|
|
cond_false:
|
2006-12-31 06:02:00 +00:00
|
|
|
ret i32 42
|
2006-11-27 01:05:10 +00:00
|
|
|
}
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test3:
|
2010-02-27 07:36:59 +00:00
|
|
|
; CHECK: testb $1, (%eax)
|
2006-11-27 19:54:23 +00:00
|
|
|
|
2010-02-27 07:36:59 +00:00
|
|
|
define i32 @test4(i8* %ptr) nounwind {
|
2007-01-13 05:06:52 +00:00
|
|
|
%tmp = ptrtoint i8* %ptr to i1
|
|
|
|
br i1 %tmp, label %cond_true, label %cond_false
|
2006-11-27 19:54:23 +00:00
|
|
|
cond_true:
|
2006-12-31 06:02:00 +00:00
|
|
|
ret i32 21
|
2006-11-27 19:54:23 +00:00
|
|
|
cond_false:
|
2006-12-31 06:02:00 +00:00
|
|
|
ret i32 42
|
2006-11-27 19:54:23 +00:00
|
|
|
}
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test4:
|
2010-02-27 07:36:59 +00:00
|
|
|
; CHECK: testb $1, 4(%esp)
|
2006-11-27 19:54:23 +00:00
|
|
|
|
2010-02-27 07:36:59 +00:00
|
|
|
define i32 @test5(double %d) nounwind {
|
2007-01-13 05:06:52 +00:00
|
|
|
%tmp = fptosi double %d to i1
|
|
|
|
br i1 %tmp, label %cond_true, label %cond_false
|
2006-11-27 19:54:23 +00:00
|
|
|
cond_true:
|
2006-12-31 06:02:00 +00:00
|
|
|
ret i32 21
|
2006-11-27 19:54:23 +00:00
|
|
|
cond_false:
|
2006-12-31 06:02:00 +00:00
|
|
|
ret i32 42
|
2006-11-27 19:54:23 +00:00
|
|
|
}
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test5:
|
2009-11-22 15:15:52 +00:00
|
|
|
; CHECK: testb $1
|