llvm-mirror/test/CodeGen/X86/pr26350.ll
David Majnemer 05fc1c63f9 [X86] Don't transform X << 1 to X + X during type legalization
While legalizing a 64-bit shift left by 1, the following occurs:

We split the shift operand in half: a high half and a low half.
We then create an ADDC with the low half and a ADDE with the high half +
the carry bit from the ADDC.

This is problematic if X is any_ext'd because the high half computation
is now undef + undef + carry bit and there is no way to ensure that the
two undef values had the same bitwise representation.  This results in
the lowest bit in the high half turning into garbage.

Instead, do not try to turn shifts into arithmetic during type
legalization.

This fixes PR26350.

llvm-svn: 259065
2016-01-28 18:20:05 +00:00

22 lines
608 B
LLVM

; RUN: llc -disable-constant-hoisting < %s | FileCheck %s
target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
target triple = "i386-unknown-linux-gnu"
@d = global i32 8, align 4
define i32 @main() {
entry:
%load = load i32, i32* @d, align 4
%conv1 = zext i32 %load to i64
%shl = shl i64 %conv1, 1
%mul = and i64 %shl, 4294967312
%cmp = icmp ugt i64 4294967295, %mul
%zext = zext i1 %cmp to i32
ret i32 %zext
}
; CHECK: main:
; CHECK: movl d, %[[load:.*]]
; CHECK: movl %[[load]], %[[copy:.*]]
; CHECK: shrl $31, %[[copy]]
; CHECK: addl %[[load]], %[[load]]