[llvm] r179478 - Document the decision to assume that the cost of floats is twice as much as integers.

Hal Finkel hfinkel at anl.gov
Fri Feb 21 11:19:12 PST 2014


----- Original Message -----
> From: "Nadav Rotem" <nrotem at apple.com>
> To: llvm-commits at cs.uiuc.edu
> Sent: Sunday, April 14, 2013 12:55:18 AM
> Subject: [llvm] r179478 - Document the decision to assume that the cost of	floats is twice as much as integers.
> 
> Author: nadav
> Date: Sun Apr 14 00:55:18 2013
> New Revision: 179478
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179478&view=rev
> Log:
> Document the decision to assume that the cost of floats is twice as
> much as integers.

It looks like this is designed to be a throughput assumption, and while this is certainly right on Sandy Bridge, Haswell and similar, it is wrong for many other platforms (non-Intel cores such as Bulldozer, many different PowerPC cores, etc.)

Should we add some kind of getDefaultFloatThroughput() callback to handle this? Alternatively, X86TTI could return '2' for scalar floating point arithmetic operations. Does anyone have a preference?

 -Hal

> 
> Modified:
>     llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp?rev=179478&r1=179477&r2=179478&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp (original)
> +++ llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp Sun Apr 14
> 00:55:18 2013
> @@ -205,11 +205,13 @@ unsigned BasicTTI::getArithmeticInstrCos
>    std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
>  
>    bool IsFloat = Ty->getScalarType()->isFloatingPointTy();
> +  // Assume that floating point arithmetic operations cost twice as
> much as
> +  // integer operations.
>    unsigned OpCost = (IsFloat ? 2 : 1);
>  
>    if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
>      // The operation is legal. Assume it costs 1.
> -    // If the type is split to multiple registers, assume that thre
> is some
> +    // If the type is split to multiple registers, assume that there
> is some
>      // overhead to this.
>      // TODO: Once we have extract/insert subvector cost we need to
>      use them.
>      if (LT.first > 1)
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list