1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=-bmi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-NOBMI
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-BMI
5 declare i32 @llvm.smax.i32(i32, i32)
6 declare i32 @llvm.smin.i32(i32, i32)
7 declare i64 @llvm.smax.i64(i64, i64)
8 declare i64 @llvm.smin.i64(i64, i64)
10 define i32 @test_i32_smax(i32 %a) nounwind {
11 ; CHECK-NOBMI-LABEL: test_i32_smax:
12 ; CHECK-NOBMI: # %bb.0:
13 ; CHECK-NOBMI-NEXT: xorl %eax, %eax
14 ; CHECK-NOBMI-NEXT: testl %edi, %edi
15 ; CHECK-NOBMI-NEXT: cmovgl %edi, %eax
16 ; CHECK-NOBMI-NEXT: retq
18 ; CHECK-BMI-LABEL: test_i32_smax:
20 ; CHECK-BMI-NEXT: movl %edi, %eax
21 ; CHECK-BMI-NEXT: sarl $31, %eax
22 ; CHECK-BMI-NEXT: andnl %edi, %eax, %eax
23 ; CHECK-BMI-NEXT: retq
24 %r = call i32 @llvm.smax.i32(i32 %a, i32 0)
28 define i32 @test_i32_smin(i32 %a) nounwind {
29 ; CHECK-LABEL: test_i32_smin:
31 ; CHECK-NEXT: movl %edi, %eax
32 ; CHECK-NEXT: sarl $31, %eax
33 ; CHECK-NEXT: andl %edi, %eax
35 %r = call i32 @llvm.smin.i32(i32 %a, i32 0)
39 define i64 @test_i64_smax(i64 %a) nounwind {
40 ; CHECK-NOBMI-LABEL: test_i64_smax:
41 ; CHECK-NOBMI: # %bb.0:
42 ; CHECK-NOBMI-NEXT: xorl %eax, %eax
43 ; CHECK-NOBMI-NEXT: testq %rdi, %rdi
44 ; CHECK-NOBMI-NEXT: cmovgq %rdi, %rax
45 ; CHECK-NOBMI-NEXT: retq
47 ; CHECK-BMI-LABEL: test_i64_smax:
49 ; CHECK-BMI-NEXT: movq %rdi, %rax
50 ; CHECK-BMI-NEXT: sarq $63, %rax
51 ; CHECK-BMI-NEXT: andnq %rdi, %rax, %rax
52 ; CHECK-BMI-NEXT: retq
53 %r = call i64 @llvm.smax.i64(i64 %a, i64 0)
57 define i64 @test_i64_smin(i64 %a) nounwind {
58 ; CHECK-LABEL: test_i64_smin:
60 ; CHECK-NEXT: movq %rdi, %rax
61 ; CHECK-NEXT: sarq $63, %rax
62 ; CHECK-NEXT: andq %rdi, %rax
64 %r = call i64 @llvm.smin.i64(i64 %a, i64 0)