Fix generic shift expansion when shift amount is 0
authorPawel Bylica <chfast@gmail.com>
Tue, 21 Apr 2015 06:28:36 +0000 (06:28 +0000)
committerPawel Bylica <chfast@gmail.com>
Tue, 21 Apr 2015 06:28:36 +0000 (06:28 +0000)
commit775c174b7bf5a80b93ad1107c374c1c40a9a8458
tree47dff2da2aee20defba942f8a99235aaca05d36d
parentb1675e53552b818d1724bdfb8d5b3bdcf6db6266
Fix generic shift expansion when shift amount is 0

Summary:
This fixes http://llvm.org/bugs/show_bug.cgi?id=16439.

This is one possible way to approach this. The other would be to split InL>>(nbits-Amt) into (InL>>(nbits-1-Amt))>>1, which is also valid since since we only need to care about Amt up nbits-1. It's hard to tell which one is better since the shift might be expensive if this stage of expansion is not yet a legal machine integer, whereas comparisons with zero are relatively cheap at all sizes, but more expensive than a shift if the shift is on a legal machine type.

Patch by Keno Fischer!

Test Plan: regression test from http://reviews.llvm.org/D7752

Reviewers: chfast, resistor

Reviewed By: chfast, resistor

Subscribers: sanjoy, resistor, chfast, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235370 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
test/CodeGen/X86/shift-i256.ll