1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx < %s -o - | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Regressed test from https://github.com/llvm/llvm-project/issues/61923
8 define void @test_loop(ptr align 1 %src, ptr align 1 %dest, i32 %len) {
9 ; CHECK-LABEL: test_loop:
10 ; CHECK: # %bb.0: # %entry
11 ; CHECK-NEXT: cmpl $32, %edx
12 ; CHECK-NEXT: jb .LBB0_4
13 ; CHECK-NEXT: # %bb.1: # %memcmp.loop.preheader
14 ; CHECK-NEXT: movl %edx, %eax
15 ; CHECK-NEXT: andl $-32, %eax
16 ; CHECK-NEXT: xorl %ecx, %ecx
17 ; CHECK-NEXT: .p2align 4, 0x90
18 ; CHECK-NEXT: .LBB0_2: # %memcmp.loop
19 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
20 ; CHECK-NEXT: vmovups (%rsi,%rcx), %ymm0
21 ; CHECK-NEXT: vxorps (%rdi,%rcx), %ymm0, %ymm0
22 ; CHECK-NEXT: vptest %ymm0, %ymm0
23 ; CHECK-NEXT: jne .LBB0_4
24 ; CHECK-NEXT: # %bb.3: # %memcmp.loop.latch
25 ; CHECK-NEXT: # in Loop: Header=BB0_2 Depth=1
26 ; CHECK-NEXT: addq $32, %rcx
27 ; CHECK-NEXT: cmpq %rax, %rcx
28 ; CHECK-NEXT: jb .LBB0_2
29 ; CHECK-NEXT: .LBB0_4: # %done
30 ; CHECK-NEXT: vzeroupper
33 %len.wide = zext i32 %len to i64
34 %elements.len = lshr i64 %len.wide, 0
35 %loop.entry.cond = icmp uge i64 %elements.len, 32
36 br i1 %loop.entry.cond, label %memcmp.loop.preheader, label %done
38 memcmp.loop.preheader: ; preds = %entry
39 %memcmp.loop.iters = lshr i64 %elements.len, 5
40 %memcmp.loop.elements = shl i64 %memcmp.loop.iters, 5
43 memcmp.loop: ; preds = %memcmp.loop.latch, %memcmp.loop.preheader
44 %vector.index = phi i64 [ 0, %memcmp.loop.preheader ], [ %vector.index.next, %memcmp.loop.latch ]
45 %left.vector_start_ptr = getelementptr inbounds i8, ptr %dest, i64 %vector.index
46 %right.vector_start_ptr = getelementptr inbounds i8, ptr %src, i64 %vector.index
47 %left.vector = load <32 x i8>, ptr %left.vector_start_ptr, align 1
48 %right.vector = load <32 x i8>, ptr %right.vector_start_ptr, align 1
49 %vec.cmp = icmp eq <32 x i8> %left.vector, %right.vector
50 %vec.cmp.reduced = call i1 @llvm.vector.reduce.and.v32i1(<32 x i1> %vec.cmp)
51 br i1 %vec.cmp.reduced, label %memcmp.loop.latch, label %done
53 memcmp.loop.latch: ; preds = %memcmp.loop
54 %vector.index.next = add i64 %vector.index, 32
55 %loop.continue = icmp ult i64 %vector.index.next, %memcmp.loop.elements
56 br i1 %loop.continue, label %memcmp.loop, label %done
62 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
63 declare i1 @llvm.vector.reduce.and.v32i1(<32 x i1>) #2