[PATCH] D158053: [PowerPC] Implement llvm.maximum/minimum intrinsic

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 23:30:55 PDT 2023


qiucf created this revision.
qiucf added reviewers: nemanjai, shchenz, stefanp, PowerPC, tlively, RKSimon, e-kud.
Herald added subscribers: steven.zhang, pengfei, kbarton, hiraditya, kristof.beyls.
Herald added a project: All.
qiucf requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

According to langref, `llvm.maximum` propagates NaNs while `llvm.maxnum` does not, which means `maximum(1, nan)=nan, maxnum(1, nan)=1`.

PowerPC does not have native instruction for such facility, the intrinsic is lowered into two-way comparison instead: choosing the normal maximum and then compare against NaN.

The code sequence is tested to have the same behavior with AArch64's (`maximum(1, snan)=qnan`), while on X86 `maximum(1, snan)=snan`. I think it's not specified by langref so both quiet it or not are acceptable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158053

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/test/CodeGen/PowerPC/fminimum-fmaximum-f128.ll
  llvm/test/CodeGen/PowerPC/fminimum-fmaximum.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158053.550628.patch
Type: text/x-patch
Size: 21524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/5727b3c6/attachment.bin>


More information about the llvm-commits mailing list