[PATCH] D103180: [InstSimplify] Add constant fold for extractelement + splat for scalable vectors

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 3 02:00:59 PDT 2021


sdesmalen added inline comments.


================
Comment at: llvm/lib/IR/ConstantFold.cpp:913
   if (auto *ValSVTy = dyn_cast<ScalableVectorType>(Val->getType())) {
     if (!CIdx->uge(ValSVTy->getMinNumElements())) {
+      if (Constant *SplatVal = Val->getSplatValue())
----------------
dmgreen wrote:
> sdesmalen wrote:
> > CarolineConcatto wrote:
> > > sdesmalen wrote:
> > > > nit: `s/!CIdx->uge/CIdx->ult/`
> > > Hey @sdesmalen 
> > > I may be completely wrong, but I believe your suggestion is not possible
> > > https://llvm.org/doxygen/classllvm_1_1ConstantInt.html
> > > If I looked the documentation correctly llvm::constant only has UGE
> > Ah I hadn't realised that. In that case, could you write it more explicitly as
> >   CIdx->getZExtValue() < ValSVTy->getMinNumElements()
> Do we know the type of CIdx is always less that 64bits?
> 
> uge() is just a convenience wrapper around APInt::uge(). You can use CIdx->getValue().ult(..) if you feel the ult is better than the !uge
Agreed, that's better, my main concern was the `!uge`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103180/new/

https://reviews.llvm.org/D103180



More information about the llvm-commits mailing list