mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add constant folding support for bitcasts of splat vectors to integers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -46,7 +46,16 @@ using namespace llvm;
|
||||
static Constant *FoldBitCast(Constant *C, Type *DestTy,
|
||||
const TargetData &TD) {
|
||||
|
||||
// This only handles casts to vectors currently.
|
||||
ConstantVector *CV = dyn_cast<ConstantVector>(C);
|
||||
IntegerType *IntVTy = dyn_cast<IntegerType>(DestTy);
|
||||
// When casting vectors to scalar integers, catch the
|
||||
// obvious splat cases.
|
||||
if (IntVTy && CV) {
|
||||
if (CV->isNullValue()) return ConstantInt::getNullValue(IntVTy);
|
||||
if (CV->isAllOnesValue()) return ConstantInt::getAllOnesValue(IntVTy);
|
||||
}
|
||||
|
||||
// The code below only handles casts to vectors currently.
|
||||
VectorType *DestVTy = dyn_cast<VectorType>(DestTy);
|
||||
if (DestVTy == 0)
|
||||
return ConstantExpr::getBitCast(C, DestTy);
|
||||
@@ -59,7 +68,6 @@ static Constant *FoldBitCast(Constant *C, Type *DestTy,
|
||||
}
|
||||
|
||||
// If this is a bitcast from constant vector -> vector, fold it.
|
||||
ConstantVector *CV = dyn_cast<ConstantVector>(C);
|
||||
if (CV == 0)
|
||||
return ConstantExpr::getBitCast(C, DestTy);
|
||||
|
||||
|
Reference in New Issue
Block a user