[PATCH] D153660: [ConstraintElim] Track and simplify conditions at use.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 27 07:00:58 PDT 2023
fhahn updated this revision to Diff 534967.
fhahn added a comment.
Address latest comments, thanks!
In D153660#4452297 <https://reviews.llvm.org/D153660#4452297>, @nikic wrote:
> Can you please also add a test along these lines?
>
> define i1 @test(i1 %c, i32 %x) {
> entry:
> br i1 %c, label %if, label %join
>
> if:
> %cmp1 = icmp sgt i32 %x, 1
> %cmp2 = icmp sgt i32 %x, 0
> br i1 %cmp1, label %join, label %exit
>
> join:
> %phi = phi i1 [ %cmp2, %if ], [ false, %entry ]
> ret i1 %phi
>
> exit:
> ret i1 false
> }
>
> Here the fact is known only along the edge, but in neither of the blocks. I don't expect this to actually get folded...
Yep, if the fact is only known on the edge then we don't simplify it at the moment. This could probably be handled by making the fact handling more fine-grained.
I *think* this should already be covered by the following test. It's a 3 entry phi, not sure if it is worth adding a dedicated simpler case? https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/ConstraintElimination/cond-used-in-phi.ll#L221
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.534967.patch
Type: text/x-patch
Size: 13379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230627/64ce30ae/attachment.bin>
More information about the llvm-commits
mailing list