[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:12:25 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 (";
----------------
paulwalker-arm wrote:
The splat printing follows the same style as used for ConstantExprs.
https://github.com/llvm/llvm-project/pull/112548
More information about the cfe-commits
mailing list