[PATCH] D63958: [SDAG] commute setcc operands to match a subtract

Jacques Pienaar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 13:49:20 PDT 2019


jpienaar accepted this revision.
jpienaar added a comment.
This revision is now accepted and ready to land.

Lanai side looks good to me, thanks!



================
Comment at: llvm/test/CodeGen/Lanai/sub-cmp-peephole.ll:28
 ; CHECK-NEXT:    sub.f %r7, %r6, %r3
-; CHECK-NEXT:    sel.lt %r3, %r0, %rv
+; CHECK-NEXT:    sel.gt %r3, %r0, %rv
 ; CHECK-NEXT:    ld -4[%fp], %pc ! return
----------------
spatel wrote:
> jpienaar wrote:
> > The select compare changes, but the operands to the subtract doesn't, that seems weird.
> If I'm reading this asm correctly based on the linked doc:
> http://g.co/lanai/isa 
> 
> We have:
>  %a == %r6 , %b == %r7
> so "sub.f %r7, %r6, %r3" means "b-a" goes into %r3
> And "sel.gt %r3, %r0, %rv" means "b-a" goes into "rv" if "b-a" was greater than 0.
> 
> That matches the IR logic, so is the code miscompiled without this patch? If we have "sel.lt", then that means the returned value is negative or zero rather than the intended positive or zero?
You are correct.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63958/new/

https://reviews.llvm.org/D63958





More information about the llvm-commits mailing list