[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
Tue Oct 22 08:48:18 PDT 2024
================
@@ -1687,6 +1692,46 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
return;
}
+ // When in the mode where Constant{Int,FP} do not support vector types the
+ // "splat(Ty val)" syntax is interpreted as a ConstantDataVector. Maintaining
+ // this association when outputiing the IR will significantly reduce the
+ // output changes when in the mode where Constant{Int,FP} do support vector
+ // types. In turn this should make it easier to spot difference in output
+ // when switching between the modes. Once the transition is complete this
+ // code will be removed.
+ if (const ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(CV)) {
+ if (auto *SplatVal = CDV->getSplatValue()) {
+ Type* EltTy = SplatVal->getType();
+
+ if (EltTy->isIntegerTy() && !UseConstantIntForFixedLengthSplat) {
----------------
paulwalker-arm wrote:
As predicted the conditions did not affect the behaviour and have been removed.
The one place where constants are still printed as `<Ty V1, Ty V2...>` is shufflevector masks, which go down a dedicated path. I've kept this as is for now because figure non-zero splat masks are rare and `ShuffleVectorInst::isValidOperands` currently rejects `ConstantInt` anyway.
https://github.com/llvm/llvm-project/pull/112548
More information about the cfe-commits
mailing list