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)
commit57c2f7c75648ae3c706d815a0d23f002545b7214
treea211dd396d6ea3aeb26c9ee889b5b3f22d32f8f4
parent2718fb1d69fbba728ac636032432811aceb098d6
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

llvm-svn: 235370
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/test/CodeGen/X86/shift-i256.ll