[X86] Custom lower UINT_TO_FP from v4f32 to v4i32, and for v8f32 to v8i32 if
authorQuentin Colombet <qcolombet@apple.com>
Tue, 11 Nov 2014 02:23:47 +0000 (02:23 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Tue, 11 Nov 2014 02:23:47 +0000 (02:23 +0000)
commit8201185d616cf9a11b130a00cf5a92a156cc322b
treef8984fff696167d715413fddcea631f4e1c67c56
parentbc741c1c42d080638953759f7ccc7c2a9a5fe143
[X86] Custom lower UINT_TO_FP from v4f32 to v4i32, and for v8f32 to v8i32 if
AVX2 is available.
According to IACA, the new lowering has a throughput of 8 cycles instead of 13
with the previous one.

Althought this lowering kicks in some SPECs benchmarks, the performance
improvement was within the noise.

Correctness testing has been done for the whole range of uint32_t with the
following program:
    uint4 v = (uint4) {0,1,2,3};
    uint32_t i;

    //Check correctness over entire range for uint4 -> float4 conversion
    for( i = 0; i < 1U << (32-2); i++ )
    {
        float4 t = test(v);
        float4 c = correct(v);

        if( 0xf != _mm_movemask_ps( t == c ))
        {
            printf( "Error @ %vx: %vf vs. %vf\n", v, c, t);
            return -1;
        }

        v += 4;
    }
Where "correct" is the old lowering and "test" the new one.

The patch adds a test case for the two custom lowering instruction.
It also modifies the vector cost model, which is why cast.ll and uitofp.ll are
modified.
2009-02-26-MachineLICMBug.ll is also modified because we now hoist 7
instructions instead of 4 (3 more constant loads).

rdar://problem/18153096>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221657 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86TargetTransformInfo.cpp
test/Analysis/CostModel/X86/cast.ll
test/Analysis/CostModel/X86/uitofp.ll
test/CodeGen/X86/2009-02-26-MachineLICMBug.ll
test/CodeGen/X86/vec_uint_to_fp.ll