[clang] [llvm] [LLVM][IR] Use splat syntax when printing Constant[Data]Vector. (PR #112548)
Paul Walker via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 31 04:10:42 PDT 2024
================
@@ -1690,6 +1690,23 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
if (isa<ConstantVector>(CV) || isa<ConstantDataVector>(CV)) {
auto *CVVTy = cast<FixedVectorType>(CV->getType());
Type *ETy = CVVTy->getElementType();
+
+ // Use the same shorthand for splat vector (i.e. "splat(Ty val)") as is
+ // permitted on IR input to reduce the output changes when enabling
+ // UseConstant{Int,FP}ForFixedLengthSplat.
+ // TODO: Remove this block when the UseConstant{Int,FP}ForFixedLengthSplat
+ // options are removed.
+ if (auto *SplatVal = CV->getSplatValue()) {
+ if (isa<ConstantInt>(SplatVal) || isa<ConstantFP>(SplatVal)) {
+ Out << "splat (";
+ WriterCtx.TypePrinter->print(ETy, Out);
+ Out << " ";
+ WriteAsOperandInternal(Out, SplatVal, WriterCtx);
+ Out << ")";
+ return;
----------------
paulwalker-arm wrote:
Done.
https://github.com/llvm/llvm-project/pull/112548
More information about the cfe-commits
mailing list