1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 3 ; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s 4 5 declare i32 @llvm.AMDGPU.bfm(i32, i32) nounwind readnone 6 7 ; FUNC-LABEL: {{^}}bfm_arg_arg: 8 ; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}} 9 ; EG: BFM_INT 10 define void @bfm_arg_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind { 11 %bfm = call i32 @llvm.AMDGPU.bfm(i32 %src0, i32 %src1) nounwind readnone 12 store i32 %bfm, i32 addrspace(1)* %out, align 4 13 ret void 14 } 15 16 ; FUNC-LABEL: {{^}}bfm_arg_imm: 17 ; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x7b 18 ; EG: BFM_INT 19 define void @bfm_arg_imm(i32 addrspace(1)* %out, i32 %src0) nounwind { 20 %bfm = call i32 @llvm.AMDGPU.bfm(i32 %src0, i32 123) nounwind readnone 21 store i32 %bfm, i32 addrspace(1)* %out, align 4 22 ret void 23 } 24 25 ; FUNC-LABEL: {{^}}bfm_imm_arg: 26 ; SI: s_bfm_b32 {{s[0-9]+}}, 0x7b, {{s[0-9]+}} 27 ; EG: BFM_INT 28 define void @bfm_imm_arg(i32 addrspace(1)* %out, i32 %src1) nounwind { 29 %bfm = call i32 @llvm.AMDGPU.bfm(i32 123, i32 %src1) nounwind readnone 30 store i32 %bfm, i32 addrspace(1)* %out, align 4 31 ret void 32 } 33 34 ; FUNC-LABEL: {{^}}bfm_imm_imm: 35 ; SI: s_bfm_b32 {{s[0-9]+}}, 0x7b, 0x1c8 36 ; EG: BFM_INT 37 define void @bfm_imm_imm(i32 addrspace(1)* %out) nounwind { 38 %bfm = call i32 @llvm.AMDGPU.bfm(i32 123, i32 456) nounwind readnone 39 store i32 %bfm, i32 addrspace(1)* %out, align 4 40 ret void 41 } 42 43 ; FUNC-LABEL: {{^}}bfm_pattern: 44 ; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}} 45 define void @bfm_pattern(i32 addrspace(1)* %out, i32 %x, i32 %y) { 46 %a = shl i32 1, %x 47 %b = sub i32 %a, 1 48 %c = shl i32 %b, %y 49 store i32 %c, i32 addrspace(1)* %out 50 ret void 51 } 52 53 ; FUNC-LABEL: {{^}}bfm_pattern_simple: 54 ; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0 55 define void @bfm_pattern_simple(i32 addrspace(1)* %out, i32 %x) { 56 %a = shl i32 1, %x 57 %b = sub i32 %a, 1 58 store i32 %b, i32 addrspace(1)* %out 59 ret void 60 } 61