[llvm-commits] [llvm] r48254 - in /llvm/trunk: lib/Transforms/IPO/IPConstantPropagation.cpp test/Transforms/IPConstantProp/return-constants.ll

Devang Patel dpatel at apple.com
Thu Mar 20 10:59:28 PDT 2008


On Mar 19, 2008, at 9:43 PM, Chris Lattner wrote:

>>  for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
>>    if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
>> +      assert (N == RI->getNumOperands() && "Invalid ReturnInst  
>> operands!");
>> +      for (unsigned i = 0; i < N; ++i) {
>> +        if (isa<UndefValue>(RI->getOperand(i))) {
>> +          // Ignore
>> +        } else if (Constant *C = dyn_cast<Constant>(RI- 
>> >getOperand(i))) {
>> +          Value *RV = RetVals[i];
>> +          if (RV == 0)
>> +            RetVals[i] = C;
>> +          else if (RV != C)
>> +            return false; // Does not return the same constant.
>
> This isn't right: some retvals could be constant while others  
> aren't.  You need a value to represent "not constant".  If this  
> happens, set the value to 'not constant' and count how many values  
> get marked 'not constant'.  If that count ever equals  
> RetVals.size(), *then* you return false.


Well, the current setup is more conservative because it rejects  
multiple ret vals where one or more individual values may be constant  
but not all values are constant.

I'll fix it.
-
Devang






More information about the llvm-commits mailing list