brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 079dd52 Raw
97 lines · plain
1; RUN: llc < %s -mtriple=i686-- -stackrealign -O2 | FileCheck %s2; PR287553 4; Check that register allocator is able to handle that5; a-lot-of-fixed-and-reserved-registers case. We do that by6; emmiting lea before 4 cmpxchg8b operands generators.7 8define void @foo_alloca(ptr %a, i32 %off, i32 %n) {9  %dummy = alloca i32, i32 %n10  %addr = getelementptr inbounds i64, ptr %a, i32 %off11 12  %res = cmpxchg ptr %addr, i64 0, i64 1 monotonic monotonic13  ret void14}15 16; CHECK-LABEL: foo_alloca17; CHECK: leal    {{\(%e..,%e..,.*\)}}, [[REGISTER:%e.i]]18; CHECK-NEXT: xorl    %eax, %eax19; CHECK-NEXT: xorl    %edx, %edx20; CHECK-NEXT: xorl    %ecx, %ecx21; CHECK-NEXT: movl    $1, %ebx22; CHECK-NEXT: lock            cmpxchg8b       ([[REGISTER]])23 24; If we don't use index register in the address mode -25; check that we did not generate the lea.26define void @foo_alloca_direct_address(ptr %addr, i32 %n) {27  %dummy = alloca i32, i32 %n28 29  %res = cmpxchg ptr %addr, i64 0, i64 1 monotonic monotonic30  ret void31}32 33; CHECK-LABEL: foo_alloca_direct_address34; CHECK-NOT: leal    {{\(%e.*\)}}, [[REGISTER:%e.i]]35; CHECK: lock            cmpxchg8b       ([[REGISTER]])36 37; We used to have a bug when combining:38; - base pointer for stack frame (VLA + alignment)39; - cmpxchg8b frameindex + index reg40 41declare void @escape(ptr)42 43define void @foo_alloca_index(i32 %i, i64 %val) {44entry:45  %Counters = alloca [19 x i64], align 3246  %vla = alloca i32, i32 %i47  call void @escape(ptr %vla)48  br label %body49 50body:51  %p = getelementptr inbounds [19 x i64], ptr %Counters, i32 0, i32 %i52  %t2 = cmpxchg volatile ptr %p, i64 %val, i64 %val seq_cst seq_cst53  %t3 = extractvalue { i64, i1 } %t2, 054  %cmp.i = icmp eq i64 %val, %t355  br i1 %cmp.i, label %done, label %body56 57done:58  ret void59}60 61; Check that we add a LEA62; CHECK-LABEL: foo_alloca_index:63; CHECK: leal    {{[0-9]*\(%e..,%e..,8\), %e..}}64; CHECK: lock            cmpxchg8b       ({{%e..}})65 66 67 68; We used to have a bug when combining:69; - base pointer for stack frame (VLA + alignment)70; - cmpxchg8b global + index reg71 72@Counters = external dso_local global [19 x i64]73 74define void @foo_alloca_index_global(i32 %i, i64 %val) {75entry:76  %aligner = alloca i32, align 3277  call void @escape(ptr %aligner)78  %vla = alloca i32, i32 %i79  call void @escape(ptr %vla)80  br label %body81 82body:83  %p = getelementptr inbounds [19 x i64], ptr @Counters, i32 0, i32 %i84  %t2 = cmpxchg volatile ptr %p, i64 %val, i64 %val seq_cst seq_cst85  %t3 = extractvalue { i64, i1 } %t2, 086  %cmp.i = icmp eq i64 %val, %t387  br i1 %cmp.i, label %done, label %body88 89done:90  ret void91}92 93; Check that we add a LEA94; CHECK-LABEL: foo_alloca_index_global:95; CHECK: leal    {{Counters\(,%e..,8\), %e..}}96; CHECK: lock            cmpxchg8b       ({{%e..}})97