[PATCH] D129191: [IndVars] Eliminate redundant type cast between integer and float
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 7 04:06:38 PDT 2022
Allen marked 3 inline comments as done.
Allen added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:681
+ if (!SE->isSCEVable(IVOperand->getType()))
+ return false;
+
----------------
nikic wrote:
> This is probably not needed, as SIToFP operand must be an integer, which is always SCEVable.
done, thanks!
================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:683
+
+ if (UseInst->getOpcode() != CastInst::SIToFP || !UseInst->hasOneUse())
+ return false;
----------------
nikic wrote:
> Why do we care about hasOneUse here? This seems at odds with your users() loop below.
yes, it can be deleted, thanks @nikic
================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:687
+ // Get the symbolic expression for this instruction.
+ ConstantRange IVRange = SE->getUnsignedRange(SE->getSCEV(IVOperand));
+ unsigned DestNumSigBits = UseInst->getType()->getFPMantissaWidth();
----------------
nikic wrote:
> getSignedRange?
good catch, thanks!
================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:698
+ CI->replaceUsesWithIf(IVOperand, [&](Use &U) -> bool {
+ return DT->dominates(IVOperand, U);
+ });
----------------
nikic wrote:
> How can IVOperand not dominate U? IVOperands dominates UseInst, which dominates all its uses.
thanks, I updated it with replaceAllUsesWith.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:699
+ return DT->dominates(IVOperand, U);
+ });
+
----------------
nikic wrote:
> There may be a type mismatch here: Either we need to limit to the same type, or insert sext/trunc as necessary.
thanks, I add limit to the same type now.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129191/new/
https://reviews.llvm.org/D129191
More information about the llvm-commits
mailing list