[PATCH] D91120: [DAGCombine][PowerPC] Fold negated abs to avoid generating `select_cc`

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 21:03:16 PST 2020


steven.zhang added a comment.

In D91120#2391105 <https://reviews.llvm.org/D91120#2391105>, @spatel wrote:

> Note that we are planning to canonicalize IR to the abs() intrinsic - D87188 <https://reviews.llvm.org/D87188>.
> Assuming that comes through relatively soon (cc @nikic), should we hold off adding what would probably become dead code in the backend?

That is good news. But we still need to combine the sub(0, abs) to sradi/xor/sub as it saves one instruction. 
What we have now with D87188 <https://reviews.llvm.org/D87188>:

  0:	76 fe 64 7c 	sradi   r4,r3,63
  4:	14 22 63 7c 	add     r3,r3,r4
  8:	78 22 63 7c 	xor     r3,r3,r4
  c:	d0 00 63 7c 	neg     r3,r3

And it can be improved to:

  0:	76 fe 60 7c 	sradi   r0,r3,63
  4:	78 02 63 7c 	xor     r3,r3,r0
  8:	50 00 63 7c 	subf    r3,r3,r0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91120



More information about the llvm-commits mailing list