OSDN Git Service

[DAGCombiner] allow narrowing of add followed by truncate
authorSanjay Patel <spatel@rotateright.com>
Sat, 22 Dec 2018 17:10:31 +0000 (17:10 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sat, 22 Dec 2018 17:10:31 +0000 (17:10 +0000)
commit4452b74d5714e239904aac24e564e43db4ff7351
treef0a5750a2d7b7fab895c2a4650256430a5e478d3
parented78f25ec768a0556ba432ac1ce4751a97c156d4
[DAGCombiner] allow narrowing of add followed by truncate

trunc (add X, C ) --> add (trunc X), C'

If we're throwing away the top bits of an 'add' instruction, do it in the narrow destination type.
This makes the truncate-able opcode list identical to the sibling transform done in IR (in instcombine).

This change used to show regressions for x86, but those are gone after D55494.
This gets us closer to deleting the x86 custom function (combineTruncatedArithmetic)
that does almost the same thing.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350006 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AMDGPU/imm16.ll
test/CodeGen/AMDGPU/trunc-combine.ll
test/CodeGen/Hexagon/vect/vect-vaslw.ll
test/CodeGen/X86/load-combine.ll
test/CodeGen/X86/pr32329.ll
test/CodeGen/X86/pr32345.ll
test/CodeGen/X86/pr33290.ll
test/CodeGen/X86/pr34381.ll
test/CodeGen/X86/pr35765.ll
test/CodeGen/X86/scheduler-backtracking.ll