[PATCH] D92095: [DAG] Legalize abs(x) -> smax(x,sub(0,x)) iff smax/sub are legal

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 05:37:12 PST 2020


RKSimon created this revision.
RKSimon added reviewers: spatel, lebedev.ri, nemanjai, craig.topper.
Herald added subscribers: steven.zhang, pengfei, kbarton, hiraditya.
Herald added a project: LLVM.
RKSimon requested review of this revision.

If smax() is legal, this is likely to result in smaller codegen expansion for abs(x) than the xor(add,ashr) method.

This is also what powerpc has been doing for its abs implementation, so it lets us get rid of a load of custom lowering code there (and which was never updated when they added smax lowering).

Alive2 check : https://alive2.llvm.org/ce/z/xRk3cD


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92095

Files:
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/test/CodeGen/X86/abs.ll
  llvm/test/CodeGen/X86/combine-abs.ll
  llvm/test/CodeGen/X86/viabs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92095.307593.patch
Type: text/x-patch
Size: 8290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201125/7e62ad81/attachment.bin>


More information about the llvm-commits mailing list