[PATCH] D153660: [ConstraintElim] Track and simplify conditions at use.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 26 03:21:26 PDT 2023


fhahn updated this revision to Diff 534484.
fhahn marked an inline comment as done.
fhahn added a comment.

In D153660#4447236 <https://reviews.llvm.org/D153660#4447236>, @nikic wrote:

> The case I had in mind is something like this:
>
>   define i1 @test(i32 %x) {
>   entry:
>     %cmp1 = icmp sgt i32 %x, 1
>     br i1 %cmp1, label %if, label %join
>   
>   if:
>     %cmp2 = icmp sgt i32 %x, 0
>     br label %join
>   
>   join:
>     %phi = phi i1 [ %cmp2, %if ], [ false, %entry ]
>     ret i1 %phi
>   }
>
> Where the `%cmp1` fact dominates the `%cmp2` use, but not if we consider the `%cmp2` use to be in `%join`.

Ah yes, not an issue during the replacement but where we queue. Added tests in 81e3779a131f <https://reviews.llvm.org/rG81e3779a131f2fb14762d848984c90dff14636bf> and updated the code to use the branch instruction of the incoming block as context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153660

Files:
  llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
  llvm/test/Transforms/ConstraintElimination/and-implied-by-operands.ll
  llvm/test/Transforms/ConstraintElimination/assumes.ll
  llvm/test/Transforms/ConstraintElimination/cond-used-in-phi.ll
  llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-crashes.ll
  llvm/test/Transforms/ConstraintElimination/uses-in-different-blocks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153660.534484.patch
Type: text/x-patch
Size: 13331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230626/c933bca5/attachment-0001.bin>


More information about the llvm-commits mailing list