[PATCH] D63992: [InstCombine] Y - ~X --> X + Y + 1 fold (PR42457)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 09:40:23 PDT 2019
spatel added a reviewer: efriedma.
spatel added a comment.
Not sure which way to go here - a 'not' is considered a less complex op than arbitrary xor/add, and 'not' might be better for value tracking and subsequent instcombines. But the adds are reassociable/commutable.
This might warrant a DAGCombiner patch to avoid regressions before we make the IR decision.
x86 scalar looks better with add+inc:
movl %edi, %eax
notl %esi
subl %esi, %eax
vs.
leal 1(%rsi,%rdi), %eax
But AArch64 and PowerPC64LE appear to benefit from the 'not' with vector code:
mvn v1.16b, v1.16b
sub v0.4s, v0.4s, v1.4s
vs.
add v0.4s, v1.4s, v0.4s
movi v1.4s, #1
add v0.4s, v0.4s, v1.4s
And PPC:
xxlnor 35, 35, 35
vsubuwm 2, 2, 3
vs.
vspltisw 4, 1
vadduwm 2, 3, 2
vadduwm 2, 2, 4
If we do go in this direction, do we want to increment 1st to reduce the burden on -reassociation? Assuming it will do:
(x + y) + 1 --> (x + 1) + y
...we might as well produce that directly?
cc'ing Eli in case he sees any other motivations to consider.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63992/new/
https://reviews.llvm.org/D63992
More information about the llvm-commits
mailing list