xref: /llvm-project/llvm/test/CodeGen/X86/sbb-zero-idiom.ll (revision 40a50f8701a99a063a9950fc0a41f46934e4e160)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2
3; Check the attribute.
4
5; RUN: llc < %s -mtriple=x86_64-- -mattr=-sbb-dep-breaking | FileCheck %s --check-prefixes=ZERO
6; RUN: llc < %s -mtriple=x86_64-- -mattr=+sbb-dep-breaking | FileCheck %s --check-prefixes=IDIOM
7
8; And check that CPUs have included the attribute as expected.
9
10; RUN: llc < %s -mtriple=x86_64--                   | FileCheck %s --check-prefixes=ZERO
11; RUN: llc < %s -mtriple=x86_64-- -mcpu=sandybridge | FileCheck %s --check-prefixes=ZERO
12; RUN: llc < %s -mtriple=x86_64-- -mcpu=skylake     | FileCheck %s --check-prefixes=ZERO
13; RUN: llc < %s -mtriple=x86_64-- -mcpu=k8          | FileCheck %s --check-prefixes=IDIOM
14; RUN: llc < %s -mtriple=x86_64-- -mcpu=btver1      | FileCheck %s --check-prefixes=IDIOM
15; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver2      | FileCheck %s --check-prefixes=IDIOM
16; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver3      | FileCheck %s --check-prefixes=IDIOM
17
18define i32 @i32_select_0_or_neg1(i32 %x) {
19; ZERO-LABEL: i32_select_0_or_neg1:
20; ZERO:       # %bb.0:
21; ZERO-NEXT:    xorl %eax, %eax
22; ZERO-NEXT:    negl %edi
23; ZERO-NEXT:    sbbl %eax, %eax
24; ZERO-NEXT:    retq
25;
26; IDIOM-LABEL: i32_select_0_or_neg1:
27; IDIOM:       # %bb.0:
28; IDIOM-NEXT:    negl %edi
29; IDIOM-NEXT:    sbbl %eax, %eax
30; IDIOM-NEXT:    retq
31  %cmp = icmp ne i32 %x, 0
32  %sel = select i1 %cmp, i32 -1, i32 0
33  ret i32 %sel
34}
35