[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)
commit4b537aaf6deb42260a1fc11980a73bdeda853fb4
tree69a572775e8a51ad95f5ce0896f73349645cee63
parent52c02d70e276aa1e138b9f43988de60838aacb8c
[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

llvm-svn: 350006
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AMDGPU/imm16.ll
llvm/test/CodeGen/AMDGPU/trunc-combine.ll
llvm/test/CodeGen/Hexagon/vect/vect-vaslw.ll
llvm/test/CodeGen/X86/load-combine.ll
llvm/test/CodeGen/X86/pr32329.ll
llvm/test/CodeGen/X86/pr32345.ll
llvm/test/CodeGen/X86/pr33290.ll
llvm/test/CodeGen/X86/pr34381.ll
llvm/test/CodeGen/X86/pr35765.ll
llvm/test/CodeGen/X86/scheduler-backtracking.ll