• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefix=X64
4
5; These tests just check that the plumbing is in place for @llvm.bswap. The
6; actual output is massive at the moment as llvm.bswap is not yet legal.
7
8declare i32 @llvm.bswap.i32(i32) readnone
9declare i32 @llvm.bswap.v4i32(i32) readnone
10
11; fold (bswap undef) -> undef
12define i32 @test_undef() nounwind {
13; X86-LABEL: test_undef:
14; X86:       # %bb.0:
15; X86-NEXT:    retl
16;
17; X64-LABEL: test_undef:
18; X64:       # %bb.0:
19; X64-NEXT:    retq
20  %b = call i32 @llvm.bswap.i32(i32 undef)
21  ret i32 %b
22}
23
24; fold (bswap (bswap x)) -> x
25define i32 @test_bswap_bswap(i32 %a0) nounwind {
26; X86-LABEL: test_bswap_bswap:
27; X86:       # %bb.0:
28; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
29; X86-NEXT:    retl
30;
31; X64-LABEL: test_bswap_bswap:
32; X64:       # %bb.0:
33; X64-NEXT:    movl %edi, %eax
34; X64-NEXT:    retq
35  %b = call i32 @llvm.bswap.i32(i32 %a0)
36  %c = call i32 @llvm.bswap.i32(i32 %b)
37  ret i32 %c
38}
39
40define i32 @test_demandedbits_bswap(i32 %a0) nounwind {
41; X86-LABEL: test_demandedbits_bswap:
42; X86:       # %bb.0:
43; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
44; X86-NEXT:    bswapl %eax
45; X86-NEXT:    andl $-65536, %eax # imm = 0xFFFF0000
46; X86-NEXT:    retl
47;
48; X64-LABEL: test_demandedbits_bswap:
49; X64:       # %bb.0:
50; X64-NEXT:    movl %edi, %eax
51; X64-NEXT:    bswapl %eax
52; X64-NEXT:    andl $-65536, %eax # imm = 0xFFFF0000
53; X64-NEXT:    retq
54  %b = or i32 %a0, 4278190080
55  %c = call i32 @llvm.bswap.i32(i32 %b)
56  %d = and i32 %c, 4294901760
57  ret i32 %d
58}
59