Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing fminimum/fmaximum vp reduction intrinsics #64940

Open
dcaballe opened this issue Aug 23, 2023 · 1 comment
Open

Missing fminimum/fmaximum vp reduction intrinsics #64940

dcaballe opened this issue Aug 23, 2023 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior vectorization

Comments

@dcaballe
Copy link
Contributor

‘llvm.vector.reduce.fminimum.*’ and ‘llvm.vector.reduce.fmaximum.*’ have been recently added to the IR. However, there is no masked variant for them. It would be great if they could be added.

(Nit: there is also certain inconsistency with the naming of the scalar and vector reduction non-NaN propagating intrinsics. ‘llvm.minnum.*’ and ‘llvm.maxnum.*’ are used for the scalar ones and fmin/fmax suffixed are used for both the predicated and non-predicated vector reduction versions. We should consider renaming them all to minnum/maxnum or fmin/fmax.)

CC: @simoll, @rofirrim, @topperc, @unterumarmung

@dcaballe dcaballe added bug Indicates an unexpected problem or unintended behavior vectorization labels Aug 23, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 23, 2023

@llvm/issue-subscribers-bug

dcaballe pushed a commit that referenced this issue Sep 13, 2023
…eductions

This patch is part of a larger initiative aimed at fixing floating-point `max` and `min` operations in MLIR: https://discourse.llvm.org/t/rfc-fix-floating-point-max-and-min-operations-in-mlir/72671.

Within LLVM, there are no masked reduction counterparts for vector reductions such as `fmaximum` and `fminimum`.
More information can be found here: #64940 (comment).

To address this issue in MLIR, where we need to generate appropriate lowerings for these cases, we employ regular non-masked intrinsics.
However, we modify the input vector using the `arith.select` operation to effectively deactivate undesired elements using a "neutral mask value".
The neutral mask value is the smallest possible value for the `fmaximum` reduction and the largest possible value for the `fminimum` reduction.

Depends on D158618

Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D158773
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this issue Sep 19, 2023
…eductions

This patch is part of a larger initiative aimed at fixing floating-point `max` and `min` operations in MLIR: https://discourse.llvm.org/t/rfc-fix-floating-point-max-and-min-operations-in-mlir/72671.

Within LLVM, there are no masked reduction counterparts for vector reductions such as `fmaximum` and `fminimum`.
More information can be found here: llvm#64940 (comment).

To address this issue in MLIR, where we need to generate appropriate lowerings for these cases, we employ regular non-masked intrinsics.
However, we modify the input vector using the `arith.select` operation to effectively deactivate undesired elements using a "neutral mask value".
The neutral mask value is the smallest possible value for the `fmaximum` reduction and the largest possible value for the `fminimum` reduction.

Depends on D158618

Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D158773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior vectorization
Projects
None yet
Development

No branches or pull requests

2 participants