Re: [Beignet] [PATCH V4] backend: add global immediate optimization

2017-06-30 Thread Ivan Shapovalov
On 2017-06-30 at 15:36 +0300, Ivan Shapovalov wrote:
> On 2017-06-30 at 01:46 +, Wang, Rander wrote:
> > Hi,
> > 
> > The abs of UD has to be done if it is encoded in instruction no
> > matter it make sense or not.
> > And I have discussed with my collage and refine it.
> > First we inspect the HW behavior of ABS(UD), -(UD) and find
> > that
> > ABS(UD) = UD,
> > -(UD) = the result of -(UD) on CPU.
> > 
> > So the abs calculation can be removed and this will make it
> > compiled pass.
> > 
> > Rander 
> 
> Hi,
> 
> OK, but what about reading from .value.ud if the corresponding .type
> is
> not GEN_TYPE_UD? Is this a concern? Which operand type combinations
> are
> possible?
> 

I mean, due to an || in the conditional it looks like it is possible
for either of the operands to not be a GEN_TYPE_D. Suppose the first
operand is a signed dword (GEN_TYPE_D) that holds a negative value and
has the ABS flag. In this case the new code will yield a significantly
wrong result. Is this possible?

-- 
Ivan Shapovalov / intelfx /

signature.asc
Description: This is a digitally signed message part
___
Beignet mailing list
Beignet@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet


Re: [Beignet] [PATCH V4] backend: add global immediate optimization

2017-06-30 Thread Ivan Shapovalov
On 2017-06-30 at 01:46 +, Wang, Rander wrote:
> Hi,
> 
>   The abs of UD has to be done if it is encoded in instruction no
> matter it make sense or not.
> And I have discussed with my collage and refine it.
> First we inspect the HW behavior of ABS(UD), -(UD) and find that
> ABS(UD) = UD,
> -(UD) = the result of -(UD) on CPU.
> 
>   So the abs calculation can be removed and this will make it
> compiled pass.
> 
> Rander 

Hi,

OK, but what about reading from .value.ud if the corresponding .type is
not GEN_TYPE_UD? Is this a concern? Which operand type combinations are
possible?

-- 
Ivan Shapovalov / intelfx /

> 
> -Original Message-
> From: Ivan Shapovalov [mailto:inte...@intelfx.name] 
> Sent: Wednesday, June 28, 2017 8:54 AM
> To: Wang, Rander ; beignet@lists.freedesktop.o
> rg
> Cc: Song, Ruiling 
> Subject: Re: [Beignet] [PATCH V4] backend: add global immediate
> optimization
> 
> On 2017-06-14 at 13:55 +0800, rander.wanga wrote:
> > there are some global immediates in global var list of
> > LLVM.
> > these imm can be integrated in instructions. for 
> > compiler_global_immediate_optimized test
> > in utest, there are two global immediates:
> > L0:
> > MOV(1)  %42<0>:UD   :   0x0:UD
> > MOV(1)  %43<0>:UD   :   0x30:UD
> > 
> > used by:
> > ADD(16) %49<1>:D:   %42<0,1,0>:
> > D 
> >%48<8,8,1>:D
> > ADD(16) %54<1>:D:   %43<0,1,0>:
> > D 
> >%53<8,8,1>:D
> > 
> > it can be
> > ADD(16) %49<1>:D:   %48<8,8,1>:D   
> > 0x
> > 0:UD
> > ADD(16) %54<1>:D:   %53<8,8,1>:D   
> > 0x
> > 30:UD
> > 
> > Then the MOV can be removed. And after this optimization, ADD 0
> > can 
> > be change
> > to MOV, then local copy propagation can be done.
> > 
> > V2: (1) add environment variable to enable/disable the
> > optimization
> > (2) refine the architecture of imm optimization, inherit
> > from 
> > global
> > optimizer not local block optimizer
> > 
> > V3: merge with latest master driver
> > 
> > V4: (1)refine some type errors
> > (2)remove UD/D check for no need
> > (3)refine imm calculate for UD/D
> > 
> > Signed-off-by: rander.wang 
> > ---
> >  .../src/backend/gen_insn_selection_optimize.cpp| 367
> > +++--
> >  1 file changed, 342 insertions(+), 25 deletions(-)
> > 
> > diff --git a/backend/src/backend/gen_insn_selection_optimize.cpp
> > b/backend/src/backend/gen_insn_selection_optimize.cpp
> > index 07547ec..eb93a20 100644
> > --- a/backend/src/backend/gen_insn_selection_optimize.cpp
> > +++ b/backend/src/backend/gen_insn_selection_optimize.cpp
> > @@ -40,6 +40,33 @@ namespace gbe
> >  return elements;
> >}
> >  
> > +  class ReplaceInfo
> > +  {
> > +  public:
> > +ReplaceInfo(SelectionInstruction ,
> > +const GenRegister ,
> > +const GenRegister ) : insn(insn),
> > intermedia(intermedia), replacement(replacement)
> > +{
> > +  assert(insn.opcode == SEL_OP_MOV || insn.opcode ==
> > SEL_OP_ADD);
> > +  assert(&(insn.dst(0)) == );
> > +  this->elements = CalculateElements(intermedia,
> > insn.state.execWidth);
> > +  replacementOverwritten = false;
> > +}
> > +~ReplaceInfo()
> > +{
> > +  this->toBeReplaceds.clear();
> > +}
> > +
> > +SelectionInstruction 
> > +const GenRegister 
> > +uint32_t elements;
> > +const GenRegister 
> > +set toBeReplaceds;
> > +set toBeReplacedInsns;
> > +bool replacementOverwritten;
> > +GBE_CLASS(ReplaceInfo);
> > +  };
> > +
> >class SelOptimizer
> >{
> >public:
> > @@ -66,32 +93,7 @@ namespace gbe
> >  
> >private:
> >  // local copy propagation
> > -class ReplaceInfo
> > -{
> > -public:
> > -  ReplaceInfo(SelectionInstruction& insn,
> > -  const GenRegister& intermedia,
> > -  const GenRegister& replacement) :
> > -  insn(insn), intermedia(intermedia),
> > replacement(replacement)
> > -  {
> > -assert(insn.opcode == SEL_OP_MOV || insn.opcode ==
> > SEL_OP_ADD);
> > -assert(&(insn.dst(0)) == );
> > -this->elements = CalculateElements(intermedia,
> > insn.state.execWidth);
> > -replacementOverwritten = false;
> > -  }
> > -  ~ReplaceInfo()
> > -  {
> > -this->toBeReplaceds.clear();
> > -  }
> >  
> > -  SelectionInstruction& insn;
> > -  const GenRegister& intermedia;
> > -  uint32_t elements;
> > -  const GenRegister& replacement;
> > -  set toBeReplaceds;
> > -  bool replacementOverwritten;
> > -  GBE_CLASS(ReplaceInfo);
> > -};
> >  typedef 

[Beignet] [PATCH] backend: refine global immediate optimization

2017-06-30 Thread rander.wang
for ABS(UD) = UD on Gen, so delete it,
or it make compilation failed on some platform

Signed-off-by: rander.wang 
---
 backend/src/backend/gen_insn_selection_optimize.cpp | 4 
 1 file changed, 4 deletions(-)

diff --git a/backend/src/backend/gen_insn_selection_optimize.cpp 
b/backend/src/backend/gen_insn_selection_optimize.cpp
index eb93a20..08e4ccf 100644
--- a/backend/src/backend/gen_insn_selection_optimize.cpp
+++ b/backend/src/backend/gen_insn_selection_optimize.cpp
@@ -424,14 +424,10 @@ namespace gbe
 else if(src0.type == GEN_TYPE_UD || src1.type == GEN_TYPE_UD)
 {
   unsigned int s0 = src0.value.ud;
-  if (src0.absolute)
-s0 = abs(s0);
   if (src0.negation)
 s0 = -s0;
 
   unsigned int s1 = src1.value.ud;
-  if (src1.absolute)
-s1 = abs(s1);
   if (src1.negation)
 s1 = -s1;
 
-- 
2.7.4

___
Beignet mailing list
Beignet@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet