mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Revert r220349 to re-instate r220277 with a fix for PR21330 -- quite
clearly only exactly equal width ptrtoint and inttoptr casts are no-op casts, it says so right there in the langref. Make the code agree. Original log from r220277: Teach the load analysis to allow finding available values which require inttoptr or ptrtoint cast provided there is datalayout available. Eventually, the datalayout can just be required but in practice it will always be there today. To go with the ability to expose available values requiring a ptrtoint or inttoptr cast, helpers are added to perform one of these three casts. These smarts are necessary to finish canonicalizing loads and stores to the operational type requirements without regressing fundamental combines. I've added some test cases. These should actually improve as the load combining and store combining improves, but they may fundamentally be highlighting some missing combines for select in addition to exercising the specific added logic to load analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222739 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -176,8 +176,13 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
|
||||
|
||||
Type *AccessTy = cast<PointerType>(Ptr->getType())->getElementType();
|
||||
|
||||
// If we're using alias analysis to disambiguate get the size of *Ptr.
|
||||
uint64_t AccessSize = AA ? AA->getTypeStoreSize(AccessTy) : 0;
|
||||
// Try to get the DataLayout for this module. This may be null, in which case
|
||||
// the optimizations will be limited.
|
||||
const DataLayout *DL = ScanBB->getDataLayout();
|
||||
|
||||
// Try to get the store size for the type.
|
||||
uint64_t AccessSize = DL ? DL->getTypeStoreSize(AccessTy)
|
||||
: AA ? AA->getTypeStoreSize(AccessTy) : 0;
|
||||
|
||||
Value *StrippedPtr = Ptr->stripPointerCasts();
|
||||
|
||||
@ -202,7 +207,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
|
||||
if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
|
||||
if (AreEquivalentAddressValues(
|
||||
LI->getPointerOperand()->stripPointerCasts(), StrippedPtr) &&
|
||||
CastInst::isBitCastable(LI->getType(), AccessTy)) {
|
||||
CastInst::isBitOrNoopPointerCastable(LI->getType(), AccessTy, DL)) {
|
||||
if (AATags)
|
||||
LI->getAAMetadata(*AATags);
|
||||
return LI;
|
||||
@ -214,7 +219,8 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
|
||||
// (This is true even if the store is volatile or atomic, although
|
||||
// those cases are unlikely.)
|
||||
if (AreEquivalentAddressValues(StorePtr, StrippedPtr) &&
|
||||
CastInst::isBitCastable(SI->getValueOperand()->getType(), AccessTy)) {
|
||||
CastInst::isBitOrNoopPointerCastable(SI->getValueOperand()->getType(),
|
||||
AccessTy, DL)) {
|
||||
if (AATags)
|
||||
SI->getAAMetadata(*AATags);
|
||||
return SI->getOperand(0);
|
||||
|
Reference in New Issue
Block a user