[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 19 Jul 2016 15:07:43 +0000 (15:07 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 19 Jul 2016 15:07:43 +0000 (15:07 +0000)
commit0ea8d275cc97e9fbc0522068ba001666f3a50a2a
tree27849af012482d606a05ac1cb4a233a250042eea
parent9e4bd0c0705a0414cc0d1fcc66320a145aa58d5a
[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR

D20859 and D20860 attempted to replace the SSE (V)CVTTPS2DQ and VCVTTPD2DQ truncating conversions with generic IR instead.

It turns out that the behaviour of these intrinsics is different enough from generic IR that this will cause problems, INF/NAN/out of range values are guaranteed to result in a 0x80000000 value - which plays havoc with constant folding which converts them to either zero or UNDEF. This is also an issue with the scalar implementations (which were already generic IR and what I was trying to match).

This patch changes both scalar and packed versions back to using x86-specific builtins.

It also deals with the other scalar conversion cases that are runtime rounding mode dependent and can have similar issues with constant folding.

A companion clang patch is at D22105

Differential Revision: https://reviews.llvm.org/D22106

llvm-svn: 275981
14 files changed:
llvm/include/llvm/IR/IntrinsicsX86.td
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/X86/X86InstrSSE.td
llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll
llvm/test/CodeGen/X86/avx-intrinsics-x86-upgrade.ll
llvm/test/CodeGen/X86/avx-intrinsics-x86.ll
llvm/test/CodeGen/X86/sse-intrinsics-fast-isel-x86_64.ll
llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll
llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel-x86_64.ll
llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
llvm/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll
llvm/test/CodeGen/X86/sse2-intrinsics-x86.ll
llvm/test/Transforms/ConstProp/calls.ll