[llvm-commits] [llvm] r165126 - /llvm/trunk/lib/Transforms/Utils/BypassSlowDivision.cpp

Nowicki, Tyler tyler.nowicki at intel.com
Wed Oct 3 12:06:27 PDT 2012


Hi,

I'm not sure why it uses its own context, here is what I know. Context are created by CodeGenAction constructor (they don't ever seem to be passed in). This class inherited by several Emit* classes which take on different actions, such as emitting llvm IR, emitting object files, etc. The appropriate action selected when invoking the compiler.

Perhaps someone else can comment on this? 

Tyler

> -----Original Message-----
> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> bounces at cs.uiuc.edu] On Behalf Of Hal Finkel
> Sent: Wednesday, October 03, 2012 1:08 PM
> To: Gurd, Preston
> Cc: llvm-commits at cs.uiuc.edu
> Subject: Re: [llvm-commits] [llvm] r165126 -
> /llvm/trunk/lib/Transforms/Utils/BypassSlowDivision.cpp
> 
> On Wed, 03 Oct 2012 16:11:44 -0000
> Preston Gurd <preston.gurd at intel.com> wrote:
> 
> > Author: pgurd
> > Date: Wed Oct  3 11:11:44 2012
> > New Revision: 165126
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=165126&view=rev
> > Log:
> > This Patch corrects a problem whereby the optimization to use a faster
> > divide instruction (for Intel Atom) was not being done by Clang,
> > because the type context used by Clang is not the default context.
> 
> This is not a specific comment on this patch, but can you (or someone
> else) please explain why Clang would be using a different default context
> from LLVM?
> 
> Thanks again,
> Hal
> 
> >
> > It fixes the problem by getting the global context types for each
> > div/rem instruction in order to compare them against the types in the
> > BypassTypeMap.
> >
> > Tests for this will be done as a separate patch to Clang.
> >
> > Patch by Tyler Nowicki.
> >
> >
> > Modified:
> >     llvm/trunk/lib/Transforms/Utils/BypassSlowDivision.cpp
> >
> > Modified: llvm/trunk/lib/Transforms/Utils/BypassSlowDivision.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/By
> > passSlowDivision.cpp?rev=165126&r1=165125&r2=165126&view=diff
> >
> ==============================================================
> ========
> > ========
> > --- llvm/trunk/lib/Transforms/Utils/BypassSlowDivision.cpp (original)
> > +++ llvm/trunk/lib/Transforms/Utils/BypassSlowDivision.cpp Wed Oct  3
> > 11:11:44 2012 @@ -238,14 +238,24 @@ if (!UseDivOp && !UseRemOp)
> >        continue;
> >
> > +    // Skip division on vector types, only optimize integer
> > instructions
> > +    if (!J->getType()->isIntegerTy())
> > +      continue;
> > +
> > +    // Get same type in global context
> > +    IntegerType *T = cast<IntegerType>(J->getType());
> > +    IntegerType *GT = IntegerType::get(getGlobalContext(),
> > T->getBitWidth()); +
> >      // Continue if div/rem type is not bypassed
> > -    DenseMap<Type *, Type *>::const_iterator BT =
> > -      BypassTypeMap.find(J->getType());
> > -    if (BT == BypassTypeMap.end())
> > +    DenseMap<Type *, Type *>::const_iterator BI =
> > BypassTypeMap.find(GT);
> > +    if (BI == BypassTypeMap.end())
> >        continue;
> >
> > -    IntegerType *BypassType = cast<IntegerType>(BT->second);
> > -    MadeChange |= reuseOrInsertFastDiv(F, I, J, BypassType, UseDivOp,
> > +    // Get the bypass type in the original context
> > +    IntegerType *GBT = cast<IntegerType>(BI->second);
> > +    IntegerType *BT = IntegerType::get(J->getContext(),
> > GBT->getBitWidth()); +
> > +    MadeChange |= reuseOrInsertFastDiv(F, I, J, BT, UseDivOp,
> >                                         UseSignedOp, DivCache);
> >    }
> >
> >
> >
> > _______________________________________________
> > 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
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list