OSDN Git Service

[X86] Attempt to pre-truncate arithmetic operations if useful
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 4 Jan 2017 08:05:42 +0000 (08:05 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 4 Jan 2017 08:05:42 +0000 (08:05 +0000)
commita947b2a548f60cb3e40a6c7e8dfb5360d4be3321
tree7b7d17750996066695c007c2eb4e117d482df03f
parent89464296ccc76563444f67afe1560715458162d2
[X86] Attempt to pre-truncate arithmetic operations if useful

In some cases its more efficient to combine TRUNC( BINOP( X, Y ) ) --> BINOP( TRUNC( X ), TRUNC( Y ) ) if the binop is legal for the truncated types.

This is true for vector integer multiplication (especially vXi64), as well as ADD/AND/XOR/OR in cases where we only need to truncate one of the inputs at runtime (e.g. a duplicated input or an one use constant we can fold).

Further work could be done here - scalar cases (especially i64) could often benefit (if we avoid partial registers etc.), other opcodes, and better analysis of when truncating the inputs reduces costs.

I have considered implementing this for all targets within the DAGCombiner but wasn't sure we could devise a suitable cost model system that would give us the range we need.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290947 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/avx512-any_extend_load.ll
test/CodeGen/X86/i64-to-float.ll
test/CodeGen/X86/vector-trunc-math.ll