[DAGCombine] (float)((int) f) --> ftrunc (PR36617)
authorSanjay Patel <spatel@rotateright.com>
Sat, 31 Mar 2018 17:55:44 +0000 (17:55 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sat, 31 Mar 2018 17:55:44 +0000 (17:55 +0000)
commit6124cae8f7656c9c75941dc2f480404dde491200
tree20e16aa484d0322e55dd90f3316e1dc27a509c12
parent9c755450efeed58364c8bd44d17992928f3e4da7
[DAGCombine] (float)((int) f) --> ftrunc (PR36617)

fptosi / fptoui round towards zero, and that's the same behavior as ISD::FTRUNC,
so replace a pair of casts with the equivalent node. We don't have to account for
special cases (NaN, INF) because out-of-range casts are undefined.

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

llvm-svn: 328921
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/ftrunc.ll
llvm/test/CodeGen/ARM/ftrunc.ll [new file with mode: 0644]
llvm/test/CodeGen/PowerPC/fp-int128-fp-combine.ll
llvm/test/CodeGen/PowerPC/fp-to-int-to-fp.ll
llvm/test/CodeGen/PowerPC/ftrunc-vec.ll
llvm/test/CodeGen/PowerPC/no-extra-fp-conv-ldst.ll
llvm/test/CodeGen/X86/2011-10-19-widen_vselect.ll
llvm/test/CodeGen/X86/ftrunc.ll