[PATCH] D76664: [ConstantFold][NFC] Compile time optimization for large vectors
Marcello Maggioni via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 24 16:57:38 PDT 2020
kariddi added inline comments.
================
Comment at: llvm/include/llvm/IR/Constants.h:770
+ : ConstantDataSequential(ty, ConstantDataVectorVal, Data),
+ IsSplat(isSplatData(ty, Data)) {}
+ const bool IsSplat;
----------------
ThomasRaoux wrote:
> kariddi wrote:
> > This introduces a linear scan in the creation of the ConstantDataVector() class, I wonder if this might be wasteful if "isSplat()" never endsup to be called on a particular vector.
> >
> > I wonder if moving this scan in "isSplat()" and caching the result might be better (as isSplat() already was an expensive method, while the construction of ConstantDataVector was not)
> Here is an alternative solution were we lazily set IsSplat. I assume it is going to be rare that we create a constant and not have any pass call isSplat on it but it could make sense to try to keep creation cheap. What do you think of this solution?
Exactly what I was thinking about thanks!
I think there are potentially cases where isSplat() is not called when a Constant is created. An example is serialization and deserialization of bitcode, where the bitcode is read into an LLVM representation is constructed and then it is just printed out (or viceversa).
Or very late legalization passes before instruction selection.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76664/new/
https://reviews.llvm.org/D76664
More information about the llvm-commits
mailing list