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