This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Exploit type-J min/max for maximum/minimum intrinsic
AbandonedPublic

Authored by qiucf on Jul 9 2020, 1:37 AM.

Details

Reviewers
hfinkel
nemanjai
steven.zhang
jsji
Group Reviewers
Restricted Project
Summary

According to LangRef, LLVM have llvm.minimum.* and llvm.maximum.* intrinsics introduced in D52764. (besides llvm.maxnum.* and llvm.minnum.*)

Its semantics is (taking minimum as example):

If either operand is a NaN, returns NaN. Otherwise returns the lesser of the two arguments. -0.0 is considered to be less than +0.0 for this intrinsic. Note that these are the semantics specified in the draft of IEEE 754-2018.

PowerPC has type-j max/min instruction (xs(max|min)jdp) since ISA 3.0, the semantics is:

If src1 or src2 is a SNaN, an Invalid Operation exception occurs.

If src1 is a NaN, result is src1. Otherwise, if src2 is a NaN, result is src2.

Otherwise, if src1 is a Zero and src2 is a Zero and either src1 or src2 is a -Zero, the result is -Zero.

Otherwise, if src1 is a +Zero and src2 is a +Zero, the result is +Zero.

Otherwise, if src1 is less than src2, result is src1. Otherwise, result is src2.

This instruction returns the 'first' that is NaN, and respects zero signs.

One thing in confusion is whether llvm.fmaximum.* should quiet it if result is SNaN.. This instruction won't.

Diff Detail

Event Timeline

qiucf created this revision.Jul 9 2020, 1:37 AM
jsji resigned from this revision.Jun 2 2022, 7:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2022, 7:42 AM
qiucf abandoned this revision.May 15 2023, 11:02 PM

Abandon this as there's no way to emit llvm.maximum on PowerPC for now.