[PATCH] D142387: [SCCP] Use range info to prove AddInst has NUW flag.
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 03:48:13 PST 2023
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SCCPSolver.cpp:172
+ if (!Op->getType()->isIntegerTy())
+ return ConstantRange::getFull(1);
+ unsigned Bitwidth = Op->getType()->getScalarSizeInBits();
----------------
Why is this needed?
================
Comment at: llvm/lib/Transforms/Utils/SCCPSolver.cpp:182
+ return ConstantRange::getFull(Bitwidth);
+ return R.getConstantRange();
+ };
----------------
There is an SCCPInstVisitor::getConstantRange() helper -- probably that should be moved to SCCPSolver and reused here?
================
Comment at: llvm/lib/Transforms/Utils/SCCPSolver.cpp:188
+ auto NUWRange = ConstantRange::makeGuaranteedNoWrapRegion(
+ Instruction::Add, RangeA, OverflowingBinaryOperator::NoUnsignedWrap);
+ if (NUWRange.contains(RangeB)) {
----------------
Should be RangeB. Doesn't make a difference for add, but would be wrong when extending to sub.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142387/new/
https://reviews.llvm.org/D142387
More information about the llvm-commits
mailing list