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

Kai Luo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 21:28:28 PST 2020


lkail created this revision.
lkail added reviewers: PowerPC, spatel, RKSimon, steven.zhang.
Herald added subscribers: llvm-commits, shchenz, hiraditya, nemanjai.
Herald added a project: LLVM.
lkail requested review of this revision.

A pattern indicates negated abs can be folded to arithmetic operations, i.e.,

  // select (setg[te] X,  0), -X,  X ->                                                                                                                                    
  // select (setgt    X, -1), -X,  X ->                                                                                                                                    
  // select (setl[te] X,  0),  X, -X ->                                                                                                                                    
  // Y = sra (X, size(X)-1); sub (Y, xor (X, Y))

Alive2 verifications
https://alive2.llvm.org/ce/z/Ddq7iy
https://alive2.llvm.org/ce/z/fhpc4C
https://alive2.llvm.org/ce/z/yKahSm
https://alive2.llvm.org/ce/z/mnnqQU
https://alive2.llvm.org/ce/z/dMyYv4


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91120

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/PowerPC/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91120.304038.patch
Type: text/x-patch
Size: 5454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201110/206d70e8/attachment-0001.bin>


More information about the llvm-commits mailing list