[llvm-commits] [llvm] r69574 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Duncan Sands baldrick at free.fr
Mon Apr 20 22:32:29 PDT 2009


Hi Sanjiv,

> >> Before trying to introduce/eliminate cast/ext/trunc to make indices type as
> >> pointer type, make sure that the pointer size is a valid sequential index type.

I think a better approach would be to add a "get preferred type for GEP indices"
method to TargetData.  This would return getIntPtrType on most targets, and i16
on PIC16.  Then change this transform to use the type given by that method rather
than getIntPtrType.

Ciao,

Duncan.

> >>     
> >
> > what's this about?  Got a testcase?
> >
> > Ciao,
> >
> > Duncan.
> >
> >   
> Hi Duncan,
> 
> Here it is
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-April/021785.html
> 
> - Sanjiv
> >> Modified:
> >>     llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> >>
> >> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=69574&r1=69573&r2=69574&view=diff
> >>
> >> ==============================================================================
> >> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
> >> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Apr 20 01:05:54 2009
> >> @@ -10695,7 +10695,12 @@
> >>    gep_type_iterator GTI = gep_type_begin(GEP);
> >>    for (User::op_iterator i = GEP.op_begin() + 1, e = GEP.op_end();
> >>         i != e; ++i, ++GTI) {
> >> -    if (isa<SequentialType>(*GTI)) {
> >> +    // Before trying to eliminate/introduce cast/ext/trunc to make
> >> +    // indices as pointer types, make sure that the pointer size
> >> +    // makes a valid sequential index.
> >> +    const SequentialType *ST = dyn_cast<SequentialType>(*GTI);
> >> +    Value *PtrTypeVal = Constant::getNullValue(TD->getIntPtrType());
> >> +    if (ST && ST->indexValid(PtrTypeVal)) {
> >>        if (CastInst *CI = dyn_cast<CastInst>(*i)) {
> >>          if (CI->getOpcode() == Instruction::ZExt ||
> >>              CI->getOpcode() == Instruction::SExt) {
> >>
> >>
> >> _______________________________________________
> >> 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