[PATCH] D11146: [ValueTracking] Add support for floating-point minnum and maxnum
Matt Arsenault
Matthew.Arsenault at amd.com
Thu Jul 16 11:13:12 PDT 2015
arsenm added inline comments.
================
Comment at: lib/Analysis/ValueTracking.cpp:3345
@@ +3344,3 @@
+ // (0.0 <= -0.0) ? 0.0 : -0.0 // Returns 0.0
+ // fminnum(0.0, -0.0) // Returns -0.0
+ // Therefore we only proceed if at least one of the operands is known to not
----------------
This comment is inaccurate. minnum is specifically allowed to return either 0.0 or -0.0 in this case
================
Comment at: lib/Analysis/ValueTracking.cpp:3362
@@ +3361,3 @@
+ // - maxnum/minnum (C99 fmaxf()/fminf()) return the non-NaN input.
+ // - A simple C99 (a < b ? a : b) construction will return the NaN input.
+ // so here we discover exactly what NaN behavior is required/accepted.
----------------
This comment is also inaccurate.
a < b is an ordered comparison.
If a is NaN the compare is false and this will return b.
If b is NaN, this will return the NaN b. This is the behavior of the min/max_legacy AMDGPU instructions which do behave as a compare + select. minnum/maxnum can't be matched to a single compare and select except in the special no nan cases. I think the code below is doing the right thing though.
Repository:
rL LLVM
http://reviews.llvm.org/D11146
More information about the llvm-commits
mailing list