[llvm-commits] [Patch] Use TargetTransformInfo to control switch-to-lookup table transform

Hal Finkel hfinkel at anl.gov
Mon Oct 29 08:45:32 PDT 2012


----- Original Message -----
> From: "Duncan Sands" <baldrick at free.fr>
> To: llvm-commits at cs.uiuc.edu
> Cc: "Nadav Rotem" <nadav.rotem at intel.com>
> Sent: Monday, October 29, 2012 10:29:21 AM
> Subject: Re: [llvm-commits] [Patch] Use TargetTransformInfo to control switch-to-lookup table transform
> 
> Hi Hans,
> 
> > When the switch-to-lookup tables transform landed in SimplifyCFG,
> > it
> > was pointed out [1] that this could be inappropriate for some
> > targets.
> > Since there was no way at the time for the pass to know anything
> > about
> > the target, an awkward reverse-transform was added in
> > CodeGenPrepare
> > that turned lookup tables back into switches for some targets.
> >
> > The attached patch uses the new TargetTransformInfo to determine if
> > a
> > switch should be transformed, and removes
> > CodeGenPrepare::ConvertLoadToSwitch. Please take a look!
> 
> personally I think it is completely wrong to have codegen concepts
> such as
> ISD::BR_JT and ISD::BRIND leaking into the IR level:

But these concepts are not leaking into the IR layer. These are contained in Target (in lib/Target/TargetTransformImpl.cpp), and the IR layer does not see them. Also, a target could override this implementation and provide a different one. Nevertheless, the IR layer only sees an abstract interface, and if Target is not linked in, just gets a fixed generic answer.

 -Hal 

> 
> > --- a/include/llvm/Transforms/Utils/Local.h
> > +++ b/include/llvm/Transforms/Utils/Local.h
> > @@ -49,6 +49,12 @@ unsigned
> > ScalarTargetTransformImpl::getJumpBufSize() const {
> >    return TLI->getJumpBufSize();
> >  }
> >
> > +bool ScalarTargetTransformImpl::shouldBuildLookupTables() const {
> > +  return TLI->supportJumpTables() &&
> > +      (TLI->isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) ||
> > +       TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other));
> > +}
> > +
> >  //===----------------------------------------------------------------------===//
> >  //
> >  // Calls used by the vectorizers.
> 
> Ciao, Duncan.
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list