Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
2 changed files
with
24 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
; RUN: llc < %s -march=x86 | ||
; RUN: llc < %s -march=x86-64 | ||
; RUN: llc < %s -march=x86 | FileCheck %s | ||
; RUN: llc < %s -march=x86-64 -O0 | FileCheck %s -check-prefix=CHECK-X64 | ||
; RUN: llc < %s -march=x86-64 -O2 | FileCheck %s -check-prefix=CHECK-X64 | ||
|
||
define void @t(i256 %x, i256 %a, i256* nocapture %r) nounwind readnone { | ||
; CHECK-LABEL: shift1 | ||
define void @shift1(i256 %x, i256 %a, i256* nocapture %r) nounwind readnone { | ||
entry: | ||
%0 = ashr i256 %x, %a | ||
store i256 %0, i256* %r | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: shift2 | ||
define i256 @shift2(i256 %c) nounwind | ||
{ | ||
%b = shl i256 1, %c ; %c must not be a constant | ||
; Special case when %c is 0: | ||
; CHECK-X64: testb [[REG:%r[0-9]+b]], [[REG]] | ||
; CHECK-X64: cmoveq | ||
ret i256 %b | ||
} |