1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2;RUN: llc < %s | FileCheck %s
3
4; This test case failed on legalization of "shl" node. PR29058.
5
6target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-unknown-linux-gnu"
8
9@structMember = external dso_local local_unnamed_addr global i64, align 8
10
11define i32 @PR29058(i8 %x, i32 %y) {
12; CHECK-LABEL: PR29058:
13; CHECK:       # %bb.0: # %entry
14; CHECK-NEXT:    movl %esi, %ecx
15; CHECK-NEXT:    testb %dil, %dil
16; CHECK-NEXT:    movl $2147483646, %eax # imm = 0x7FFFFFFE
17; CHECK-NEXT:    cmovnel %esi, %eax
18; CHECK-NEXT:    xorl %edx, %edx
19; CHECK-NEXT:    cmpb $1, %dil
20; CHECK-NEXT:    sbbl %edx, %edx
21; CHECK-NEXT:    orb %dl, %cl
22; CHECK-NEXT:    # kill: def $cl killed $cl killed $ecx
23; CHECK-NEXT:    shll %cl, %eax
24; CHECK-NEXT:    movq %rax, structMember(%rip)
25; CHECK-NEXT:    # kill: def $eax killed $eax killed $rax
26; CHECK-NEXT:    retq
27entry:
28  %bool_1 = icmp ne i8 %x, 0
29  %bool_2 = icmp eq i8 %x, 0
30  %0 = select i1 %bool_2, i32 2147483646, i32 %y
31  %or_1 = select i1 %bool_1, i32 %y, i32 -1
32  %shl_1 = shl i32 %0, %or_1
33  %conv = zext i32 %shl_1 to i64
34  store i64 %conv, i64* @structMember, align 8
35  %tmp = select i1 %bool_2, i32 2147483646, i32 %y
36  %lnot = icmp eq i8 %x, 0
37  %or_2 = select i1 %lnot, i32 -1, i32 %y
38  %shl_2 = shl i32 %tmp, %or_2
39  ret i32 %shl_2
40}
41
42