[PATCH] D63958: [SDAG] commute setcc operands to match a subtract
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 08:16:03 PDT 2019
spatel marked an inline comment as done.
spatel added inline comments.
================
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
----------------
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?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63958/new/
https://reviews.llvm.org/D63958
More information about the llvm-commits
mailing list