[PATCH] D76611: [SCCP] Use ranges for predicate info conditions.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 5 13:53:49 PDT 2020


fhahn updated this revision to Diff 255195.
fhahn added a comment.

In D76611#1955707 <https://reviews.llvm.org/D76611#1955707>, @efriedma wrote:

> Yes, code in other passes, particularly SimplifyCFG.


Thanks, I think I know what you mean now!

Making branch on undef UB kind of trades of making it easier to assume ranges (without undef) from branch conditions, but it makes it harder to introduce branches that where not there before, as it may introduce undef. This seems tricky. As you pointed out, the sanitizer attribute has some early exits for cases that might introduce branches on poison (but in most contexts that could also be undef). I'll raise it in D76973 <https://reviews.llvm.org/D76973>. It's probably best to discuss it there and maybe extend to llvm-dev.

Regardless of the outcome, I think the patch should be fine either way: only whether the range based on the condition can include undef or not is impacted by the outcome of that discussion. As ranges are only used to simplify conditions (which should be fine either way), switching to include undef for the new ranges by default should not have any functional impact on the current transformations.

I've updated the code to mark new ranges as potentially including undef. That should be the conservative choice and correct even if branch on undef is not UB. I've also added a TODO to flip the default once more other parts of the optimizer respect 'branch on undef is UB'.

Do you think this is conservative enough to get this in, even with the open questions remaining around 'branch on undef is UB'?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76611

Files:
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Transforms/SCCP/conditions-ranges-with-undef.ll
  llvm/test/Transforms/SCCP/conditions-ranges.ll
  llvm/test/Transforms/SCCP/ip-constant-ranges.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76611.255195.patch
Type: text/x-patch
Size: 17884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200405/e47db805/attachment-0001.bin>


More information about the llvm-commits mailing list