aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2023-02-21 15:03:32 -0500
committerSanjay Patel <spatel@rotateright.com>2023-02-21 17:03:40 -0500
commitae2322a0dca9f8c39b1db51756c7155610fe668a (patch)
tree2e189c678312481d8546b251283d7655e7ff8d89 /flang/lib/Frontend/CompilerInvocation.cpp
parentbceafb7f249cc9286e54664bcfd08307b86c16b9 (diff)
downloadllvm-ae2322a0dca9f8c39b1db51756c7155610fe668a.zip
llvm-ae2322a0dca9f8c39b1db51756c7155610fe668a.tar.gz
llvm-ae2322a0dca9f8c39b1db51756c7155610fe668a.tar.bz2
[InstSimplify] enhance simplifyWithOpReplaced() to allow more 'select' removal
This is a generalization of a suggestion from issue #60799 that allows removing a redundant guard of an input value via icmp+select. It should also solve issue #60801. This only comes into play for a select with an equality condition where we are trying to substitute a constant into the false arm of a select. (A 'true' select arm substitution allows "refinement", so it is not on this code path.) The constant must be the same in the compare and the select, and it must be a "binop absorber" (X op C = C). That query currently includes 'or', 'and', and 'mul', so there are tests for all of those opcodes. We then use "impliesPoison" on the false arm binop and the original "Op" to be replaced to ensure that the select is not actually blocking poison from leaking. That could be potentially expensive as we recursively test each operand, but it is currently limited to a depth of 2. That's enough to catch our motivating cases, but probably nothing more complicated (although that seems unlikely). I don't know how to generalize a proof for Alive2 for this, but here's a positive and negative test example to help illustrate the subtle logic differences of poison/undef propagation: https://alive2.llvm.org/ce/z/Sz5K-c Differential Revision: https://reviews.llvm.org/D144493
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions