1 ; RUN: llc < %s -march=x86-64 -mattr=+sse41,-avx,+rdrand | FileCheck %s 2 3 define i32 @foo(<2 x i64> %c, i32 %a, i32 %b) { 4 %t1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c) 5 %t2 = icmp ne i32 %t1, 0 6 %t3 = select i1 %t2, i32 %a, i32 %b 7 ret i32 %t3 8 ; CHECK: foo 9 ; CHECK: ptest 10 ; CHECK-NOT: testl 11 ; CHECK: cmov 12 ; CHECK: ret 13 } 14 15 define i32 @bar(<2 x i64> %c) { 16 entry: 17 %0 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c) 18 %1 = icmp ne i32 %0, 0 19 br i1 %1, label %if-true-block, label %endif-block 20 if-true-block: ; preds = %entry 21 ret i32 0 22 endif-block: ; preds = %entry, 23 ret i32 1 24 ; CHECK: bar 25 ; CHECK: ptest 26 ; CHECK-NOT: testl 27 ; CHECK: jne 28 ; CHECK: ret 29 } 30 31 define i32 @bax(<2 x i64> %c) { 32 %t1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c) 33 %t2 = icmp eq i32 %t1, 1 34 %t3 = zext i1 %t2 to i32 35 ret i32 %t3 36 ; CHECK: bax 37 ; CHECK: ptest 38 ; CHECK-NOT: cmpl 39 ; CHECK: ret 40 } 41 42 define i32 @rnd(i32 %arg) nounwind uwtable { 43 %1 = tail call { i32, i32 } @llvm.x86.rdrand.32() nounwind 44 %2 = extractvalue { i32, i32 } %1, 0 45 %3 = extractvalue { i32, i32 } %1, 1 46 %4 = icmp eq i32 %3, 0 47 %5 = select i1 %4, i32 0, i32 %arg 48 %6 = add i32 %5, %2 49 ret i32 %6 50 ; CHECK: rnd 51 ; CHECK: rdrand 52 ; CHECK: cmov 53 ; CHECK-NOT: cmov 54 ; CHECK: ret 55 } 56 57 declare i32 @llvm.x86.sse41.ptestz(<2 x i64>, <2 x i64>) nounwind readnone 58 declare { i32, i32 } @llvm.x86.rdrand.32() nounwind 59