[PATCH] D139312: ValueTracking: Teach CannotBeOrderedLessThanZero about copysign

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 07:37:36 PST 2022


spatel added inline comments.


================
Comment at: llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll:964
+;
+  %sqrt = call ninf nnan float @llvm.sqrt.f32(float %sign)
+  %copysign = call float @llvm.copysign.f32(float %unknown, float %sqrt)
----------------
arsenm wrote:
> spatel wrote:
> > Something went wrong - this is a miscompile without 'nsz' on the sqrt (otherwise, it can return -0.0):
> > https://alive2.llvm.org/ce/z/yqXQmQ
> But this is being consumed by an fcmp - the sign of the zero shouldn't matter for the final result. Alive bug?
No - the negative sign of the -0.0 is applied to the magnitude parameter (%unknown).
So the sequence could be something like:
copysign(42.0, sqrt(-0.0)) >= 0.0
-42.0 >= 0.0 --> false


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139312/new/

https://reviews.llvm.org/D139312



More information about the llvm-commits mailing list