[all-commits] [llvm/llvm-project] 724289: [Flang] Attempt to fix Nan handling in Minloc/Maxl...
David Green via All-commits
all-commits at lists.llvm.org
Wed Feb 21 01:31:41 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7242896233635e553694507e6584decb43ee4a16
https://github.com/llvm/llvm-project/commit/7242896233635e553694507e6584decb43ee4a16
Author: David Green <david.green at arm.com>
Date: 2024-02-21 (Wed, 21 Feb 2024)
Changed paths:
M flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp
M flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
M flang/test/HLFIR/maxloc-elemental.fir
M flang/test/HLFIR/minloc-elemental.fir
M flang/test/Transforms/simplifyintrinsics.fir
Log Message:
-----------
[Flang] Attempt to fix Nan handling in Minloc/Maxloc intrinsic simplification (#82313)
In certain case "extreme" values like Nan, Inf and 0xffffffff could lead
to generating different code via the inline-generated intrinsics vs the
versions in the runtimes (and other compilers like gfortran). There are
some examples I was using for testing in
https://godbolt.org/z/x4EfqEss5.
This changes the generation for the intrinsics to be more like the
runtimes, using a condition that is similar to:
isFirst || (prev != prev && elem == elem) || elem < prev
The middle part is only used for floating point operations, and checks
if the values are Nan. This should then hopefully make the logic closer
to - return the first element with the lowest value, with Nans ignored
unless there are only Nans. The initial limit value for floats are also
changed from the largest float to Inf, to make sure it is handled
correctly.
The integer reductions are also changed to use a similar scheme to make
sure they work with masked values. This means that the preamble after
the loop can be removed.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list