[PATCH] D76459: [SCCP] Use SimplifyBinOp for non-integer constant/expressions & overdef.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 05:55:52 PDT 2020


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

Updated to mark constants as may including undef, which in turn will ensure constant ranges are marked as including undef, for integer constants.

In D76459#1940015 <https://reviews.llvm.org/D76459#1940015>, @efriedma wrote:

> The problem I see here is that InstSimplify could take a possibly-undef value, and turn it into a simple constant; then we would lose track of the fact that the value might be undef.  (For example, we transform "undef & -2 -> 0", and then incorrectly merge the result with a ConstantRange.)


Ah I see what you mean. I don't think the example "undef & -2 -> 0" would cause any issues because we get a single constant and will replace all uses. For the AND example, I think the only problem would be if a constant expression could evaluate to either undef or a constant. I cannot think of a case where this might be possible off the top of my head, but we can make sure that the constant range we create includes undef, if we simplify to an integer constant. That should conservatively preserve the fact that the result may include undef.

What do you think?

> For NewGVN, you're talking about https://bugs.llvm.org/show_bug.cgi?id=36335 ? I don't think that sort of issue applies here. The operand we're passing to InstSimplify is the operand of the actual operation, so any context InstSimplify could derive is the correct context. We don't try to apply the result to any other instruction.

Yes that was what I was thinking about. But as you said, it seems like it won't be an issue here, as we only pass constants or the original value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76459

Files:
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Transforms/SCCP/ub-shift.ll
  llvm/test/Transforms/SCCP/vector-bitcast.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76459.256264.patch
Type: text/x-patch
Size: 5931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/1626aa54/attachment.bin>


More information about the llvm-commits mailing list