mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +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:
@@ -1257,6 +1257,18 @@ public:
|
||||
return Insert(Folder.CreateIntCast(VC, DestTy, isSigned), Name);
|
||||
return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned), Name);
|
||||
}
|
||||
|
||||
Value *CreateBitOrPointerCast(Value *V, Type *DestTy,
|
||||
const Twine &Name = "") {
|
||||
if (V->getType() == DestTy)
|
||||
return V;
|
||||
if (V->getType()->isPointerTy() && DestTy->isIntegerTy())
|
||||
return CreatePtrToInt(V, DestTy, Name);
|
||||
if (V->getType()->isIntegerTy() && DestTy->isPointerTy())
|
||||
return CreateIntToPtr(V, DestTy, Name);
|
||||
|
||||
return CreateBitCast(V, DestTy, Name);
|
||||
}
|
||||
private:
|
||||
// \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
|
||||
// compile time error, instead of converting the string to bool for the
|
||||
|
||||
@@ -489,6 +489,19 @@ public:
|
||||
Instruction *InsertBefore = 0 ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// @brief Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
|
||||
///
|
||||
/// If the value is a pointer type and the destination an integer type,
|
||||
/// creates a PtrToInt cast. If the value is an integer type and the
|
||||
/// destination a pointer type, creates an IntToPtr cast. Otherwise, creates
|
||||
/// a bitcast.
|
||||
static CastInst *CreateBitOrPointerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name = "", ///< Name for the instruction
|
||||
Instruction *InsertBefore = 0 ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
|
||||
static CastInst *CreateIntegerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
@@ -551,6 +564,17 @@ public:
|
||||
Type *DestTy ///< The Type to which the value should be cast.
|
||||
);
|
||||
|
||||
/// @brief Check whether a bitcast, inttoptr, or ptrtoint cast between these
|
||||
/// types is valid and a no-op.
|
||||
///
|
||||
/// This ensures that any pointer<->integer cast has enough bits in the
|
||||
/// integer and any other cast is a bitcast.
|
||||
static bool isBitOrNoopPointerCastable(
|
||||
Type *SrcTy, ///< The Type from which the value should be cast.
|
||||
Type *DestTy, ///< The Type to which the value should be cast.
|
||||
const DataLayout *Layout = 0 ///< Optional DataLayout.
|
||||
);
|
||||
|
||||
/// Returns the opcode necessary to cast Val into Ty using usual casting
|
||||
/// rules.
|
||||
/// @brief Infer the opcode for cast operand and type
|
||||
|
||||
Reference in New Issue
Block a user