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

Sanjiv Gupta sanjiv.gupta at microchip.com
Mon Apr 20 09:16:11 PDT 2009


Dan Gohman wrote:
> Hello,
>
> Are you planning to resubmit r58505?  It was reverted in r58547 with
> a message indicating that it would be resubmitted.  That patch would
> appear to make this r69574 unnecessary.
>
> Dan
>
>   
Right. Even after that this change will still hold good just in case if 
a pointer size doesn't make valid index.
Chris had suggested that 58505 alone is not enough as the bc encoding 
uses 1 bit to encode i32/i64 for index types.
He had suggested that we should be able to write i16 type indexes and 
should be able to get back them by the command seq below.
  $ llvm-as < test.ll | llvm-dis | llvm-as | llvm-dis

When I tried this with 58505, it worked.
So the only additional thing is that we  probably need to do the changes 
in the documentation.

Let me know if this understanding is incorrect. Better you can get me a 
test case.

- Sanjiv

> On Apr 19, 2009, at 11:05 PM, Sanjiv Gupta wrote:
>
>   
>> Author: sgupta
>> Date: Mon Apr 20 01:05:54 2009
>> New Revision: 69574
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=69574&view=rev
>> Log:
>> 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.
>>
>> 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
>>     
>
> _______________________________________________
> 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