[llvm] [LLVM][IR] Add support for vector ConstantInt/FP to ConstandFolding:FoldBitCast. (PR #117163)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 05:50:36 PST 2024
================
@@ -151,8 +151,14 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
return FoldBitCast(ConstantVector::get(Ops), DestTy, DL);
}
+ // Some of what follows may extend to cover scalable vectors but the current
+ // implementation is fixed length specific.
+ if (!isa<FixedVectorType>(C->getType()))
+ return ConstantExpr::getBitCast(C, DestTy);
+
// If this is a bitcast from constant vector -> vector, fold it.
- if (!isa<ConstantDataVector>(C) && !isa<ConstantVector>(C))
+ if (!isa<ConstantDataVector>(C) && !isa<ConstantVector>(C) &&
+ !isa<ConstantInt>(C) && !isa<ConstantFP>(C))
----------------
david-arm wrote:
Refers to line 206: Do we need to add ConstantInt and ConstantFP checks here too?
https://github.com/llvm/llvm-project/pull/117163
More information about the llvm-commits
mailing list