[llvm-commits] [llvm] r169452 - /llvm/trunk/lib/Analysis/ValueTracking.cpp

Duncan Sands baldrick at free.fr
Thu Dec 6 00:53:07 PST 2012


Hi Michael,

On 06/12/12 01:07, Michael Ilseman wrote:
> Author: milseman
> Date: Wed Dec  5 18:07:09 2012
> New Revision: 169452
>
> URL: http://llvm.org/viewvc/llvm-project?rev=169452&view=rev
> Log:
> Have CannotBeNegativeZero() be aware of the nsz fast-math flag

does nsz mean that if there is a signed zero then the behaviour is undefined?
Or does it mean negative zero can be treated like positive zero, and there's no
need to get the sign of zero right?

It seems to me that your patch pretty much assumes the first case.
If it's instead the second then I think you would do better to have
instcombine turn all instances of -0.0 into +0.0.

Ciao, Duncan.

>
> Modified:
>      llvm/trunk/lib/Analysis/ValueTracking.cpp
>
> Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=169452&r1=169451&r2=169452&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
> +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Wed Dec  5 18:07:09 2012
> @@ -1312,7 +1312,12 @@
>
>     const Operator *I = dyn_cast<Operator>(V);
>     if (I == 0) return false;
> -
> +
> +  // Check if the nsz fast-math flag is set
> +  if (const FPMathOperator *FPO = dyn_cast<FPMathOperator>(I))
> +    if (FPO->hasNoSignedZeros())
> +      return true;
> +
>     // (add x, 0.0) is guaranteed to return +0.0, not -0.0.
>     if (I->getOpcode() == Instruction::FAdd &&
>         isa<ConstantFP>(I->getOperand(1)) &&
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list