[PATCH] D124118: [Peephole-Opt] For one kind of test-after-add pattern, eliminates test if it's correct to do so.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 20 16:49:41 PDT 2022
craig.topper added a comment.
In D124118#3463205 <https://reviews.llvm.org/D124118#3463205>, @davidxl wrote:
> I suspect there is something else going on.
>
> The following case works fine without the patch.
>
> define dso_local noundef i64 @_Z3fooPlll(ptr nocapture noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
>
> %4 = load i64, ptr %0, align 8
> %5 = and i64 %4, 3
> %6 = icmp eq i64 %5, 0
> %7 = select i1 %6, i64 %1, i64 %2
> store i64 %7, ptr %0, align 8
> ret i64 %5
>
> }
>
> However a simple change below to replace the operand %2 in the select with %5 (output of and operation), then it stops working.
>
> define dso_local noundef i64 @_Z3fooPlll(ptr nocapture noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
>
> %4 = load i64, ptr %0, align 8
> %5 = and i64 %4, 3
> %6 = icmp eq i64 %5, 0
> %7 = select i1 %6, i64 %1, i64 %5
> store i64 %7, ptr %0, align 8
> ret i64 %5
>
> }
>
> Can you investigate the difference? The behavior difference on ARM is also worth comparing with.
There's a peephole in X86DAGToDAGISel::Select and PostProcessISelDAG that both fail if the AND has users other than the TEST.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124118/new/
https://reviews.llvm.org/D124118
More information about the llvm-commits
mailing list