]> granicus.if.org Git - llvm/commit
[SDAG] commute setcc operands to match a subtract
authorSanjay Patel <spatel@rotateright.com>
Wed, 10 Jul 2019 23:23:54 +0000 (23:23 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 10 Jul 2019 23:23:54 +0000 (23:23 +0000)
commit4b3ebe83325f20f408689e63d27837228ce06a46
treeeca247e45e417d79bad904f12a6fd9b589e88bec
parent8e52f2768a64fea74751995f31c941aa88b5185b
[SDAG] commute setcc operands to match a subtract

If we have:

R = sub X, Y
P = cmp Y, X

...then flipping the operands in the compare instruction can allow using a subtract that sets compare flags.

Motivated by diffs in D58875 - not sure if this changes anything there,
but this seems like a good thing independent of that.

There's a more involved version of this transform already in IR (in instcombine
although that seems misplaced to me) - see "swapMayExposeCSEOpportunities()".

Differential Revision: https://reviews.llvm.org/D63958

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365711 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/TargetLowering.cpp
test/CodeGen/AArch64/arm64-shrink-wrapping.ll
test/CodeGen/AArch64/cgp-usubo.ll
test/CodeGen/Lanai/sub-cmp-peephole.ll
test/CodeGen/X86/jump_sign.ll
test/CodeGen/X86/psubus.ll