[llvm] [RISCV] and x (sub -1, y) -> andn x y (PR #129253)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 28 09:18:08 PST 2025
topperc wrote:
> And maybe, it will be enough to work on the IR level, if the suggested IR transformations are done, we will get `andn` generated: https://godbolt.org/z/z4fqW6Ejf . (When the ticket was reported it wasn't that way https://godbolt.org/z/EEvhK9ovx) .
>
> Sorry for my negligence and Thank you for you time and patience.
I don't think this can be optimized in IR. InstCombine will nearly always try to reduce critical depth if doesn't increase the number of instructions. This change is only profitable if `andn` exists for the target which InstCombine can't know. Generic DAGCombine will want to do the same.
Both InstCombine and DAGCombiner will want to turn `(xor (add X, -1), -1)` into `(sub 0, X)` regardless of how the xor is used or that `(add X, -1)` has another user.
https://github.com/llvm/llvm-project/pull/129253
More information about the llvm-commits
mailing list