[mips][FastISel] Apply only zero-extension to constants prior to their materialization.
authorVasileios Kalintiris <Vasileios.Kalintiris@imgtec.com>
Thu, 30 Jul 2015 11:51:44 +0000 (11:51 +0000)
committerVasileios Kalintiris <Vasileios.Kalintiris@imgtec.com>
Thu, 30 Jul 2015 11:51:44 +0000 (11:51 +0000)
commit3b79f0ccc33b68912c296c6151bd83a643fb9fc7
treec2f182f8f8d857d7b2d83fcd853aead1109bb3e4
parent4b26be60668f4c7654fd376f4bb8d01a06000282
[mips][FastISel] Apply only zero-extension to constants prior to their materialization.

Summary:
Previously, we would sign-extend non-boolean negative constants and
zero-extend otherwise. This was problematic for PHI instructions with
negative values that had a type with bitwidth less than that of the
register used for materialization.

More specifically, ComputePHILiveOutRegInfo() assumes the constants
present in a PHI node are zero extended in their container and
afterwards deduces the known bits.

For example, previously we would materialize an i16 -4 with the
following instruction:

  addiu $r, $zero, -4

The register would end-up with the 32-bit 2's complement representation
of -4. However, ComputePHILiveOutRegInfo() would generate a constant
with the upper 16-bits set to zero. The SelectionDAG builder would use
that information to generate an AssertZero node that would remove any
subsequent trunc & zero_extend nodes.

In theory, we should modify ComputePHILiveOutRegInfo() to consult
target-specific hooks about the way they prefer to materialize the
given constants. However, git-blame reports that this specific code
has not been touched since 2011 and it seems to be working well for every
target so far.

Reviewers: dsanders

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11592

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243636 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/Mips/MipsFastISel.cpp
test/CodeGen/Mips/Fast-ISel/logopm.ll
test/CodeGen/Mips/Fast-ISel/simplestorei.ll