1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s --check-prefix=I386
4 ; Make sure we don't zero out %eax when both %ah and %al are used.
6 ; PR1766: https://github.com/ClangBuiltLinux/linux/issues/1766
8 %struct.maple_subtree_state = type { ptr }
10 @mas_data_end_type = dso_local local_unnamed_addr global i32 0, align 4
11 @ma_meta_end_mn_0_0_0_0_0_0 = dso_local local_unnamed_addr global i8 0, align 1
12 @mt_pivots_0 = dso_local local_unnamed_addr global i8 0, align 1
13 @mas_data_end___trans_tmp_2 = dso_local local_unnamed_addr global ptr null, align 4
14 @mt_slots_0 = dso_local local_unnamed_addr global i8 0, align 1
16 define dso_local zeroext i1 @test1(ptr nocapture noundef readonly %0) local_unnamed_addr "zero-call-used-regs"="used-gpr" nounwind {
19 ; I386-NEXT: pushl %ebx
20 ; I386-NEXT: subl $24, %esp
21 ; I386-NEXT: movl {{[0-9]+}}(%esp), %eax
22 ; I386-NEXT: movl (%eax), %eax
23 ; I386-NEXT: movzbl (%eax), %ebx
24 ; I386-NEXT: calll bar
25 ; I386-NEXT: testb %al, %al
26 ; I386-NEXT: # implicit-def: $al
27 ; I386-NEXT: # kill: killed $al
28 ; I386-NEXT: je .LBB0_6
30 ; I386-NEXT: cmpl $0, mas_data_end_type
31 ; I386-NEXT: je .LBB0_3
33 ; I386-NEXT: movzbl ma_meta_end_mn_0_0_0_0_0_0, %eax
34 ; I386-NEXT: movb %al, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
35 ; I386-NEXT: jmp .LBB0_6
37 ; I386-NEXT: movb mt_pivots_0, %ah
38 ; I386-NEXT: movb %ah, %al
40 ; I386-NEXT: movl mas_data_end___trans_tmp_2, %ecx
41 ; I386-NEXT: movsbl %al, %edx
42 ; I386-NEXT: cmpl $0, (%ecx,%edx,4)
43 ; I386-NEXT: je .LBB0_5
45 ; I386-NEXT: movb %al, %ah
47 ; I386-NEXT: movb %ah, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
49 ; I386-NEXT: movb mt_slots_0, %bh
50 ; I386-NEXT: leal {{[0-9]+}}(%esp), %eax
51 ; I386-NEXT: movl %eax, (%esp)
52 ; I386-NEXT: calll baz
53 ; I386-NEXT: subl $4, %esp
54 ; I386-NEXT: cmpb %bh, %bl
55 ; I386-NEXT: jae .LBB0_8
57 ; I386-NEXT: movsbl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 1-byte Folded Reload
58 ; I386-NEXT: movl %eax, (%esp)
59 ; I386-NEXT: calll gaz
61 ; I386-NEXT: movb $1, %al
62 ; I386-NEXT: addl $24, %esp
63 ; I386-NEXT: popl %ebx
64 ; I386-NEXT: xorl %ecx, %ecx
65 ; I386-NEXT: xorl %edx, %edx
67 %2 = alloca %struct.maple_subtree_state, align 4
68 %3 = load ptr, ptr %0, align 4
69 %4 = load i8, ptr %3, align 1
70 %5 = tail call zeroext i1 @bar()
71 br i1 %5, label %6, label %20
74 %7 = load i32, ptr @mas_data_end_type, align 4
75 %8 = icmp eq i32 %7, 0
76 br i1 %8, label %11, label %9
79 %10 = load i8, ptr @ma_meta_end_mn_0_0_0_0_0_0, align 1
83 %12 = load i8, ptr @mt_pivots_0, align 1
85 %14 = load ptr, ptr @mas_data_end___trans_tmp_2, align 4
86 %15 = sext i8 %13 to i32
87 %16 = getelementptr inbounds [1 x i32], ptr %14, i32 0, i32 %15
88 %17 = load i32, ptr %16, align 4
89 %18 = icmp eq i32 %17, 0
90 %19 = select i1 %18, i8 %12, i8 %13
93 20: ; preds = %11, %9, %1
94 %21 = phi i8 [ undef, %1 ], [ %10, %9 ], [ %19, %11 ]
95 %22 = load i8, ptr @mt_slots_0, align 1
96 call void @baz(ptr nonnull sret(%struct.maple_subtree_state) align 4 %2)
97 %23 = icmp ult i8 %4, %22
98 br i1 %23, label %24, label %25
101 call void @gaz(i8 noundef signext %21)
104 25: ; preds = %20, %24
108 declare dso_local zeroext i1 @bar(...) local_unnamed_addr
110 declare dso_local void @baz(ptr sret(%struct.maple_subtree_state) align 4, ...) local_unnamed_addr
112 declare dso_local void @gaz(i8 noundef signext) local_unnamed_addr