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-prefix=CHECK-NOBMI
3; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi < %s | FileCheck %s --check-prefix=CHECK-BMI
4
5; Optimize (x > -1) to (x >= 0) etc.
6; Optimize (cmp (add / sub), 0): eliminate the subs used to update flag
7;   for comparison only
8; rdar://10233472
9
10define i32 @t1(i64 %a) {
11; CHECK-NOBMI-LABEL: t1:
12; CHECK-NOBMI:       # %bb.0:
13; CHECK-NOBMI-NEXT:    xorl %eax, %eax
14; CHECK-NOBMI-NEXT:    testq %rdi, %rdi
15; CHECK-NOBMI-NEXT:    setns %al
16; CHECK-NOBMI-NEXT:    retq
17;
18; CHECK-BMI-LABEL: t1:
19; CHECK-BMI:       # %bb.0:
20; CHECK-BMI-NEXT:    xorl %eax, %eax
21; CHECK-BMI-NEXT:    testq %rdi, %rdi
22; CHECK-BMI-NEXT:    setns %al
23; CHECK-BMI-NEXT:    retq
24  %cmp = icmp sgt i64 %a, -1
25  %conv = zext i1 %cmp to i32
26  ret i32 %conv
27}
28