From: Marek Olsak Date: Tue, 24 Mar 2015 13:40:34 +0000 (+0000) Subject: R600/SI: Select V_BFE_U32 for and+shift with a non-literal offset X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a2705bbd426b9aa391eb797ef0c21f97fd4be951;p=oota-llvm.git R600/SI: Select V_BFE_U32 for and+shift with a non-literal offset git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233079 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/R600/AMDGPUInstructions.td b/lib/Target/R600/AMDGPUInstructions.td index 849b241f63e..4d08201d55e 100644 --- a/lib/Target/R600/AMDGPUInstructions.td +++ b/lib/Target/R600/AMDGPUInstructions.td @@ -578,22 +578,20 @@ class SHA256MaPattern : Pat < // Bitfield extract patterns -/* - -XXX: The BFE pattern is not working correctly because the XForm is not being -applied. +def IMMZeroBasedBitfieldMask : PatLeaf <(imm), [{ + return isMask_32(N->getZExtValue()); +}]>; -def legalshift32 : ImmLeaf =0 && Imm < 32;}]>; -def bfemask : PatLeaf <(imm), [{return isMask_32(N->getZExtValue());}], - SDNodeXFormgetTargetConstant(countTrailingOnes(N->getZExtValue()), MVT::i32);}]>>; +def IMMPopCount : SDNodeXFormgetTargetConstant(countPopulation(N->getZExtValue()), + MVT::i32); +}]>; -class BFEPattern : Pat < - (and (srl i32:$x, legalshift32:$y), bfemask:$z), - (BFE $x, $y, $z) +class BFEPattern : Pat < + (i32 (and (i32 (srl i32:$src, i32:$rshift)), IMMZeroBasedBitfieldMask:$mask)), + (BFE $src, $rshift, (MOV (i32 (IMMPopCount $mask)))) >; -*/ - // rotr pattern class ROTRPattern : Pat < (rotr i32:$src0, i32:$src1), diff --git a/lib/Target/R600/EvergreenInstructions.td b/lib/Target/R600/EvergreenInstructions.td index 9f9472c1c17..55601469009 100644 --- a/lib/Target/R600/EvergreenInstructions.td +++ b/lib/Target/R600/EvergreenInstructions.td @@ -287,9 +287,8 @@ def BFE_INT_eg : R600_3OP <0x5, "BFE_INT", VecALU >; -// XXX: This pattern is broken, disabling for now. See comment in -// AMDGPUInstructions.td for more info. -// def : BFEPattern ; +def : BFEPattern ; + def BFI_INT_eg : R600_3OP <0x06, "BFI_INT", [(set i32:$dst, (AMDGPUbfi i32:$src0, i32:$src1, i32:$src2))], VecALU diff --git a/lib/Target/R600/SIInstructions.td b/lib/Target/R600/SIInstructions.td index 764e79b0fb3..95b2470273c 100644 --- a/lib/Target/R600/SIInstructions.td +++ b/lib/Target/R600/SIInstructions.td @@ -3339,6 +3339,8 @@ multiclass BFMPatterns { defm : BFMPatterns ; // FIXME: defm : BFMPatterns ; +def : BFEPattern ; + //===----------------------------------------------------------------------===// // Fract Patterns //===----------------------------------------------------------------------===// diff --git a/test/CodeGen/R600/bfe_uint.ll b/test/CodeGen/R600/bfe_uint.ll index 6fe23e91295..32e3fc26106 100644 --- a/test/CodeGen/R600/bfe_uint.ll +++ b/test/CodeGen/R600/bfe_uint.ll @@ -1,7 +1,5 @@ ; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s -; XFAIL: * - ; CHECK: {{^}}bfe_def: ; CHECK: BFE_UINT define void @bfe_def(i32 addrspace(1)* %out, i32 %x) { diff --git a/test/CodeGen/R600/llvm.AMDGPU.bfe.u32.ll b/test/CodeGen/R600/llvm.AMDGPU.bfe.u32.ll index 0426b3ab603..541119242a9 100644 --- a/test/CodeGen/R600/llvm.AMDGPU.bfe.u32.ll +++ b/test/CodeGen/R600/llvm.AMDGPU.bfe.u32.ll @@ -586,6 +586,16 @@ define void @lshr_and(i32 addrspace(1)* %out, i32 %a) nounwind { ret void } +; FUNC-LABEL: {{^}}v_lshr_and: +; SI: v_bfe_u32 {{v[0-9]+}}, {{s[0-9]+}}, {{v[0-9]+}}, 3 +; SI: buffer_store_dword +define void @v_lshr_and(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind { + %c = lshr i32 %a, %b + %d = and i32 %c, 7 + store i32 %d, i32 addrspace(1)* %out, align 8 + ret void +} + ; FUNC-LABEL: {{^}}and_lshr: ; SI: s_bfe_u32 {{s[0-9]+}}, {{s[0-9]+}}, 0x30006 ; SI: buffer_store_dword