1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=debugify,loop-idiom,verify -pass-remarks=loop-idiom -pass-remarks-analysis=loop-idiom -pass-remarks-output=%t.yaml -verify-each -verify-dom-info -verify-loop-info < %s -S 2>&1 | FileCheck %s
3 ; RUN: FileCheck --input-file=%t.yaml %s --check-prefixes=YAML
5 ; RUN: opt -passes=debugify,loop-idiom,verify -pass-remarks=loop-idiom -pass-remarks-analysis=loop-idiom -pass-remarks-output=%t.yaml -verify-each -verify-dom-info -verify-loop-info < %s -S 2>&1 --try-experimental-debuginfo-iterators | FileCheck %s
6 ; RUN: FileCheck --input-file=%t.yaml %s --check-prefixes=YAML
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
11 ; Check that everything still works when debuginfo is present, and that it is reasonably propagated.
13 ; void my_basic_memset(char* begin, char* end, char value) {
14 ; for( ; begin != end; ++begin)
18 ; CHECK: remark: <stdin>:4:1: Transformed loop-strided store in _Z15my_basic_memsetPcS_c function into a call to llvm.memset.p0.i64() intrinsic{{$}}
21 ; YAML-NEXT: Pass: loop-idiom
22 ; YAML-NEXT: Name: ProcessLoopStridedStore
23 ; YAML-NEXT: DebugLoc: { File: '<stdin>', Line: 4, Column: 1 }
24 ; YAML-NEXT: Function: _Z15my_basic_memsetPcS_c
26 ; YAML-NEXT: - String: 'Transformed loop-strided store in '
27 ; YAML-NEXT: - Function: _Z15my_basic_memsetPcS_c
28 ; YAML-NEXT: DebugLoc: { File: '<stdin>', Line: 1, Column: 0 }
29 ; YAML-NEXT: - String: ' function into a call to '
30 ; YAML-NEXT: - NewFunction: llvm.memset.p0.i64
31 ; YAML-NEXT: - String: '() intrinsic'
32 ; YAML-NEXT: - FromBlock: for.body
33 ; YAML-NEXT: - ToBlock: for.body.preheader
36 define void @_Z15my_basic_memsetPcS_c(ptr %ptr, ptr %end, i8 %value) {
37 ; CHECK-LABEL: @_Z15my_basic_memsetPcS_c(
39 ; CHECK-NEXT: [[PTR2:%.*]] = ptrtoint ptr [[PTR:%.*]] to i64, !dbg [[DBG15:![0-9]+]]
40 ; CHECK-NEXT: [[END1:%.*]] = ptrtoint ptr [[END:%.*]] to i64, !dbg [[DBG15]]
41 ; CHECK-NEXT: [[CMP3:%.*]] = icmp eq ptr [[PTR]], [[END]], !dbg [[DBG15]]
42 ; CHECK-NEXT: #dbg_value(i1 [[CMP3]], [[META9:![0-9]+]], !DIExpression(), [[DBG15]])
43 ; CHECK-NEXT: br i1 [[CMP3]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]], !dbg [[DBG16:![0-9]+]]
44 ; CHECK: for.body.preheader:
45 ; CHECK-NEXT: [[TMP0:%.*]] = sub i64 [[END1]], [[PTR2]], !dbg [[DBG17:![0-9]+]]
46 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR]], i8 [[VALUE:%.*]], i64 [[TMP0]], i1 false), !dbg [[DBG18:![0-9]+]]
47 ; CHECK-NEXT: br label [[FOR_BODY:%.*]], !dbg [[DBG17]]
49 ; CHECK-NEXT: [[PTR_ADDR_04:%.*]] = phi ptr [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[PTR]], [[FOR_BODY_PREHEADER]] ], !dbg [[DBG19:![0-9]+]]
50 ; CHECK-NEXT: #dbg_value(ptr [[PTR_ADDR_04]], [[META11:![0-9]+]], !DIExpression(), [[DBG19]])
51 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i8, ptr [[PTR_ADDR_04]], i64 1, !dbg [[DBG20:![0-9]+]]
52 ; CHECK-NEXT: #dbg_value(ptr [[INCDEC_PTR]], [[META13:![0-9]+]], !DIExpression(), [[DBG20]])
53 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[INCDEC_PTR]], [[END]], !dbg [[DBG21:![0-9]+]]
54 ; CHECK-NEXT: #dbg_value(i1 [[CMP]], [[META14:![0-9]+]], !DIExpression(), [[DBG21]])
55 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY]], !dbg [[DBG17]]
56 ; CHECK: for.end.loopexit:
57 ; CHECK-NEXT: br label [[FOR_END]], !dbg [[DBG22:![0-9]+]]
59 ; CHECK-NEXT: ret void, !dbg [[DBG22]]
62 %cmp3 = icmp eq ptr %ptr, %end
63 br i1 %cmp3, label %for.end, label %for.body
65 for.body: ; preds = %entry, %for.body
66 %ptr.addr.04 = phi ptr [ %incdec.ptr, %for.body ], [ %ptr, %entry ]
67 store i8 %value, ptr %ptr.addr.04, align 1
68 %incdec.ptr = getelementptr inbounds i8, ptr %ptr.addr.04, i64 1
69 %cmp = icmp eq ptr %incdec.ptr, %end
70 br i1 %cmp, label %for.end, label %for.body
72 for.end: ; preds = %for.body, %entry