blob: ee1999d168a59b7de7909b0377ae6dde599990ca [file] [log] [blame]
Chris Lattner5f52cf82009-09-15 02:22:47 +00001; RUN: llc < %s -march=x86-64 | FileCheck %s
2
3define i32 @test1(i32 %x, i32 %n, i32 %w, i32* %vp) nounwind readnone {
4entry:
5; CHECK: test1:
6; CHECK: btl
7; CHECK-NEXT: movl $12, %eax
8; CHECK-NEXT: cmovae (%rcx), %eax
9; CHECK-NEXT: ret
10
11 %0 = lshr i32 %x, %n ; <i32> [#uses=1]
12 %1 = and i32 %0, 1 ; <i32> [#uses=1]
13 %toBool = icmp eq i32 %1, 0 ; <i1> [#uses=1]
14 %v = load i32* %vp
15 %.0 = select i1 %toBool, i32 %v, i32 12 ; <i32> [#uses=1]
16 ret i32 %.0
17}
18define i32 @test2(i32 %x, i32 %n, i32 %w, i32* %vp) nounwind readnone {
19entry:
20; CHECK: test2:
21; CHECK: btl
22; CHECK-NEXT: movl $12, %eax
23; CHECK-NEXT: cmovb (%rcx), %eax
24; CHECK-NEXT: ret
25
26 %0 = lshr i32 %x, %n ; <i32> [#uses=1]
27 %1 = and i32 %0, 1 ; <i32> [#uses=1]
28 %toBool = icmp eq i32 %1, 0 ; <i1> [#uses=1]
29 %v = load i32* %vp
30 %.0 = select i1 %toBool, i32 12, i32 %v ; <i32> [#uses=1]
31 ret i32 %.0
32}
33
34
35declare void @bar(i64) nounwind
36
37define void @test3(i64 %a, i64 %b, i1 %p) nounwind {
38; CHECK: test3:
39; CHECK: cmovne %edi, %esi
40; CHECK-NEXT: movl %esi, %edi
41
42 %c = trunc i64 %a to i32
43 %d = trunc i64 %b to i32
44 %e = select i1 %p, i32 %c, i32 %d
45 %f = zext i32 %e to i64
46 call void @bar(i64 %f)
47 ret void
48}