1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
3 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names < %s | FileCheck %s
5 ; Check that the brh/brw/brd instructions are generated for the bswap
6 ; intrinsic for register operand on P10 and that the lhbrx/lwbrx/ldbrw
7 ; instructions are generated for memory operand.
9 declare i16 @llvm.bswap.i16(i16)
11 define zeroext i16 @test_nomem16(i16 zeroext %a) {
12 ; CHECK-LABEL: test_nomem16:
13 ; CHECK: # %bb.0: # %entry
14 ; CHECK-NEXT: brh r3, r3
15 ; CHECK-NEXT: clrldi r3, r3, 48
18 %0 = tail call i16 @llvm.bswap.i16(i16 %a)
22 declare i32 @llvm.bswap.i32(i32)
24 define zeroext i32 @test_nomem32(i32 zeroext %a) {
25 ; CHECK-LABEL: test_nomem32:
26 ; CHECK: # %bb.0: # %entry
27 ; CHECK-NEXT: brw r3, r3
28 ; CHECK-NEXT: clrldi r3, r3, 32
31 %0 = tail call i32 @llvm.bswap.i32(i32 %a)
35 ; Check that brh and clrldi are produced from a call to @llvm.bswap.i32
36 ; followed by a right shift of 16 (and a zero-extend at the end of the DAG).
37 define zeroext i32 @test_bswap_shift16(i32 zeroext %a) {
38 ; CHECK-LABEL: test_bswap_shift16:
39 ; CHECK: # %bb.0: # %entry
40 ; CHECK-NEXT: brh r3, r3
41 ; CHECK-NEXT: clrldi r3, r3, 48
44 %0 = tail call i32 @llvm.bswap.i32(i32 %a)
45 %shr = lshr i32 %0, 16
49 ; Check that brh are produced from a call to @llvm.bswap.i32
50 ; followed by a right shift of 16.
52 define void @test_bswap_shift16_2() {
53 ; CHECK-LABEL: test_bswap_shift16_2:
54 ; CHECK: # %bb.0: # %bb
56 ; CHECK-NEXT: std r0, 16(r1)
57 ; CHECK-NEXT: stdu r1, -32(r1)
58 ; CHECK-NEXT: .cfi_def_cfa_offset 32
59 ; CHECK-NEXT: .cfi_offset lr, 16
60 ; CHECK-NEXT: bl call_1@notoc
61 ; CHECK-NEXT: brh r3, r3
62 ; CHECK-NEXT: rldicl r3, r3, 0, 48
63 ; CHECK-NEXT: sth r3, 0(r3)
65 switch i32 undef, label %bb1 [
73 %i = call i64 @call_1()
74 %i3 = trunc i64 %i to i32
75 %i4 = call i32 @llvm.bswap.i32(i32 %i3)
76 %i5 = lshr i32 %i4, 16
77 %i6 = trunc i32 %i5 to i16
78 store i16 %i6, ptr undef, align 2
82 define zeroext i32 @test_bswap_shift18(i32 zeroext %a) {
83 ; CHECK-LABEL: test_bswap_shift18:
84 ; CHECK: # %bb.0: # %entry
85 ; CHECK-NEXT: brw r3, r3
86 ; CHECK-NEXT: rlwinm r3, r3, 14, 18, 31
89 %0 = tail call i32 @llvm.bswap.i32(i32 %a)
90 %shr = lshr i32 %0, 18
94 declare i64 @llvm.bswap.i64(i64)
96 define i64 @test_nomem64(i64 %a) {
97 ; CHECK-LABEL: test_nomem64:
98 ; CHECK: # %bb.0: # %entry
99 ; CHECK-NEXT: brd r3, r3
102 %0 = tail call i64 @llvm.bswap.i64(i64 %a)
106 define i16 @test_mem16(ptr %a) {
107 ; CHECK-LABEL: test_mem16:
108 ; CHECK: # %bb.0: # %entry
109 ; CHECK-NEXT: lhbrx r3, 0, r3
112 %0 = load i16, ptr %a, align 2
113 %1 = tail call i16 @llvm.bswap.i16(i16 %0)
117 define i32 @test_mem32(ptr %a) {
118 ; CHECK-LABEL: test_mem32:
119 ; CHECK: # %bb.0: # %entry
120 ; CHECK-NEXT: lwbrx r3, 0, r3
123 %0 = load i32, ptr %a, align 4
124 %1 = tail call i32 @llvm.bswap.i32(i32 %0)
128 define i64 @test_mem64(ptr %a) {
129 ; CHECK-LABEL: test_mem64:
130 ; CHECK: # %bb.0: # %entry
131 ; CHECK-NEXT: ldbrx r3, 0, r3
134 %0 = load i64, ptr %a, align 8
135 %1 = tail call i64 @llvm.bswap.i64(i64 %0)