[PATCH] D60395: [InstCombine] Canonicalize (-X s/ Y) to -(X s/ Y)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 14:50:59 PDT 2019
lebedev.ri added a comment.
In D60395#1458889 <https://reviews.llvm.org/D60395#1458889>, @spatel wrote:
> In D60395#1458421 <https://reviews.llvm.org/D60395#1458421>, @lebedev.ri wrote:
>
> > Given that this doesn't fall into endless loop, i guess we don't do reverse transform.
> > I'm just wondering, this is the direction we should be doing it? @spatel
>
>
> We already have these for mul:
>
> // -X * Y --> -(X * Y)
> // X * -Y --> -(X * Y)
>
> ...so that provides some precedent for the direction to move the negation.
Okay, that confirmed my suspicions.
> Is there a sibling fold for srem?
Yep!
----------------------------------------
Optimization: nsw preserved
Precondition: true
%o0 = sub nsw i8 0, %x
%r = srem i8 %o0, %y
=>
%n0 = srem i8 %x, %y
%r = sub nsw i8 0, %n0
Done: 1
Optimization is correct!
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60395/new/
https://reviews.llvm.org/D60395
More information about the llvm-commits
mailing list