Changes in directory llvm/lib/Transforms/Utils:
Local.cpp updated: 1.51 -> 1.52 --- Log message: ConstantFoldLoadThroughGEPConstantExpr wasn't handling pointers to packed types correctly. --- Diffs of the changes: (+22 -9) Local.cpp | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) Index: llvm/lib/Transforms/Utils/Local.cpp diff -u llvm/lib/Transforms/Utils/Local.cpp:1.51 llvm/lib/Transforms/Utils/Local.cpp:1.52 --- llvm/lib/Transforms/Utils/Local.cpp:1.51 Tue Jan 17 14:07:07 2006 +++ llvm/lib/Transforms/Utils/Local.cpp Thu Jan 19 17:53:23 2006 @@ -267,16 +267,29 @@ return 0; } } else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) { - const ArrayType *ATy = cast<ArrayType>(*I); - if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0; - if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) - C = CA->getOperand((unsigned)CI->getRawValue()); - else if (isa<ConstantAggregateZero>(C)) - C = Constant::getNullValue(ATy->getElementType()); - else if (isa<UndefValue>(C)) - C = UndefValue::get(ATy->getElementType()); - else + if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) { + if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0; + if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) + C = CA->getOperand((unsigned)CI->getRawValue()); + else if (isa<ConstantAggregateZero>(C)) + C = Constant::getNullValue(ATy->getElementType()); + else if (isa<UndefValue>(C)) + C = UndefValue::get(ATy->getElementType()); + else + return 0; + } else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) { + if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) return 0; + if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C)) + C = CP->getOperand((unsigned)CI->getRawValue()); + else if (isa<ConstantAggregateZero>(C)) + C = Constant::getNullValue(PTy->getElementType()); + else if (isa<UndefValue>(C)) + C = UndefValue::get(PTy->getElementType()); + else + return 0; + } else { return 0; + } } else { return 0; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits