[PATCH] D129876: [WIP][ConstantRange] Add support for multiply and left shift with nowrap flags

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 09:19:40 PDT 2022


reames created this revision.
reames added reviewers: nikic, fhahn.
Herald added subscribers: javed.absar, bollu, hiraditya, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added a project: LLVM.

This patch adds support for multiply and left shift variants which use NoWrap flags to restrict the range returned.  It directly follows the pattern already taken for add/sub, and extends it to mul/shl.

This is a WIP for two major reasons, both of which I'd appreciate some input on.

1. I don't understand the bits in add/sub about being required to return empty ranges on definite overflow.  I can see that from a precision perspective, but since both the 2s complement and saturating variants are valid implementations of the no-wrap behavior, it seems like intersecting them should always be valid.  Am I right here?  Or is my code subtly wrong?
2. Suggestions on how to test this?  I glanced at the ConstantRangeTest file, and am looking for specific guidance on which exhaustive test harness to use.  This file has gotten quite complicated.

Once complete, I plan to use this in SCEV to help refine the ranges returned for multiplies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129876

Files:
  llvm/include/llvm/IR/ConstantRange.h
  llvm/lib/IR/ConstantRange.cpp
  llvm/test/Transforms/CorrelatedValuePropagation/mul.ll
  llvm/test/Transforms/CorrelatedValuePropagation/shl.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129876.445011.patch
Type: text/x-patch
Size: 6450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220715/11ce60ee/attachment.bin>


More information about the llvm-commits mailing list