1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=arm-darwin -mattr=v6 | FileCheck %s --check-prefixes=CHECK
3; RUN: llc < %s -mtriple=thumb-darwin -mattr=v6 | FileCheck %s --check-prefixes=CHECK
4
5define void @test1(i16* nocapture %data) {
6; CHECK-LABEL: test1:
7; CHECK:       @ %bb.0: @ %entry
8; CHECK-NEXT:    ldrh r1, [r0]
9; CHECK-NEXT:    rev16 r1, r1
10; CHECK-NEXT:    strh r1, [r0]
11; CHECK-NEXT:    bx lr
12entry:
13  %0 = load i16, i16* %data, align 2
14  %1 = tail call i16 @llvm.bswap.i16(i16 %0)
15  store i16 %1, i16* %data, align 2
16  ret void
17}
18
19define void @test2(i16* nocapture %data, i16 zeroext %in) {
20; CHECK-LABEL: test2:
21; CHECK:       @ %bb.0: @ %entry
22; CHECK-NEXT:    rev16 r1, r1
23; CHECK-NEXT:    strh r1, [r0]
24; CHECK-NEXT:    bx lr
25entry:
26  %0 = tail call i16 @llvm.bswap.i16(i16 %in)
27  store i16 %0, i16* %data, align 2
28  ret void
29}
30
31define i16 @test3(i16* nocapture %data) {
32; CHECK-LABEL: test3:
33; CHECK:       @ %bb.0: @ %entry
34; CHECK-NEXT:    ldrh r0, [r0]
35; CHECK-NEXT:    rev16 r0, r0
36; CHECK-NEXT:    bx lr
37entry:
38  %0 = load i16, i16* %data, align 2
39  %1 = tail call i16 @llvm.bswap.i16(i16 %0)
40  ret i16 %1
41}
42
43declare i16 @llvm.bswap.i16(i16)
44