Skip to content

Commit 4443b37

Browse files
artagnonigogo-x86
andauthored
[LAA] Pre-commit tests exercising different types (#151091)
Pre-commit tests exercising different types of source/sink in depend_diff_types.ll, in preparation to weaken the HasSameSize check in LoopAccessAnalysis. Co-authored-by: Igor Kirillov <[email protected]>
1 parent 767ab81 commit 4443b37

File tree

1 file changed

+298
-0
lines changed

1 file changed

+298
-0
lines changed

llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,301 @@ loop:
262262
exit:
263263
ret void
264264
}
265+
266+
; i16 i32
267+
; [ . . 0 0 . . 1 1] [ 1 1 0 0 . . 1 1 ]
268+
; ^~~^ gep i8 = 1
269+
; ^ ~~ ^ iv.2 = iv + 2
270+
; ^ ~~~~~ ^ dependence distance = 4
271+
; ^ ~~~~~~~~~~~~~~~~~ ^ 8
272+
; ^ ~~~~~~~~~~~~~~~~ ^ 8
273+
; ^ ~~~~~~~~~~~~~~~~ ^ iv.next = iv + 8
274+
;
275+
; Measurements are in bytes.
276+
;
277+
; TODO: Relax the HasSameSize check; the strided accesses are
278+
; independent, as determined by both the source size and the sink size.
279+
; This test should report no dependencies.
280+
define void @different_type_sizes_strided_accesses_independent(ptr %dst) {
281+
; CHECK-LABEL: 'different_type_sizes_strided_accesses_independent'
282+
; CHECK-NEXT: loop:
283+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
284+
; CHECK-NEXT: Unknown data dependence.
285+
; CHECK-NEXT: Dependences:
286+
; CHECK-NEXT: Unknown:
287+
; CHECK-NEXT: store i16 0, ptr %gep.iv, align 2 ->
288+
; CHECK-NEXT: store i32 1, ptr %gep.4.iv, align 4
289+
; CHECK-EMPTY:
290+
; CHECK-NEXT: Run-time memory checks:
291+
; CHECK-NEXT: Grouped accesses:
292+
; CHECK-EMPTY:
293+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
294+
; CHECK-NEXT: SCEV assumptions:
295+
; CHECK-EMPTY:
296+
; CHECK-NEXT: Expressions re-written:
297+
;
298+
entry:
299+
%gep.4 = getelementptr nuw i8, ptr %dst, i64 4
300+
br label %loop
301+
302+
loop:
303+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
304+
%iv.2 = add nuw nsw i64 %iv, 2
305+
%gep.iv = getelementptr i8, ptr %dst, i64 %iv.2
306+
store i16 0, ptr %gep.iv
307+
%gep.4.iv = getelementptr i8, ptr %gep.4, i64 %iv.2
308+
store i32 1, ptr %gep.4.iv
309+
%iv.next = add nuw nsw i64 %iv, 8
310+
%ec = icmp eq i64 %iv.next, 64
311+
br i1 %ec, label %exit, label %loop
312+
313+
exit:
314+
ret void
315+
}
316+
317+
318+
; i16 i64
319+
; [ . 0 0 . 1 1 1 1] [ 1 x x 1 1 1 1 1 ]
320+
; ^~~^ gep i8 = 1
321+
; ^~~^ iv.1 = iv + 1
322+
; ^ ~~ ^ dependence distance = 3
323+
; ^ ~~~~~~~~~~~~~~~~ ^ 8
324+
; ^ ~~~~~~~~~~~~~~~~ ^ 8
325+
; ^ ~~~~~~~~~~~~~~~~ ^ iv.next = iv + 8
326+
;
327+
; TODO: Relax the HasSameSize check; this test should report a backward
328+
; loop-carried dependence.
329+
define void @different_type_sizes_strided_accesses_dependent(ptr %dst) {
330+
; CHECK-LABEL: 'different_type_sizes_strided_accesses_dependent'
331+
; CHECK-NEXT: loop:
332+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
333+
; CHECK-NEXT: Unknown data dependence.
334+
; CHECK-NEXT: Dependences:
335+
; CHECK-NEXT: Unknown:
336+
; CHECK-NEXT: store i16 0, ptr %gep.iv, align 2 ->
337+
; CHECK-NEXT: store i64 1, ptr %gep.3.iv, align 4
338+
; CHECK-EMPTY:
339+
; CHECK-NEXT: Run-time memory checks:
340+
; CHECK-NEXT: Grouped accesses:
341+
; CHECK-EMPTY:
342+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
343+
; CHECK-NEXT: SCEV assumptions:
344+
; CHECK-EMPTY:
345+
; CHECK-NEXT: Expressions re-written:
346+
;
347+
entry:
348+
%gep.3 = getelementptr nuw i8, ptr %dst, i64 3
349+
br label %loop
350+
351+
loop:
352+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
353+
%iv.1 = add nuw nsw i64 %iv, 1
354+
%gep.iv = getelementptr i8, ptr %dst, i64 %iv.1
355+
store i16 0, ptr %gep.iv
356+
%gep.3.iv = getelementptr i8, ptr %gep.3, i64 %iv.1
357+
store i64 1, ptr %gep.3.iv
358+
%iv.next = add nuw nsw i64 %iv, 8
359+
%ec = icmp eq i64 %iv.next, 64
360+
br i1 %ec, label %exit, label %loop
361+
362+
exit:
363+
ret void
364+
}
365+
366+
; Variant of the above, where the store size exceeds the dependence
367+
; distance.
368+
define void @different_type_sizes_strided_accesses_store_size_exceeds_depdist(ptr %dst) {
369+
; CHECK-LABEL: 'different_type_sizes_strided_accesses_store_size_exceeds_depdist'
370+
; CHECK-NEXT: loop:
371+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
372+
; CHECK-NEXT: Unsafe indirect dependence.
373+
; CHECK-NEXT: Dependences:
374+
; CHECK-NEXT: IndirectUnsafe:
375+
; CHECK-NEXT: store i16 0, ptr %gep.iv, align 2 ->
376+
; CHECK-NEXT: store i128 1, ptr %gep.10.iv, align 4
377+
; CHECK-EMPTY:
378+
; CHECK-NEXT: Run-time memory checks:
379+
; CHECK-NEXT: Grouped accesses:
380+
; CHECK-EMPTY:
381+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
382+
; CHECK-NEXT: SCEV assumptions:
383+
; CHECK-EMPTY:
384+
; CHECK-NEXT: Expressions re-written:
385+
;
386+
entry:
387+
%gep.10 = getelementptr nuw i8, ptr %dst, i64 10
388+
br label %loop
389+
390+
loop:
391+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
392+
%gep.iv = getelementptr i8, ptr %dst, i64 %iv
393+
store i16 0, ptr %gep.iv
394+
%gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
395+
store i128 1, ptr %gep.10.iv
396+
%iv.next = add i64 %iv, 8
397+
%ec = icmp eq i64 %iv.next, 64
398+
br i1 %ec, label %exit, label %loop
399+
400+
exit:
401+
ret void
402+
}
403+
404+
405+
; Source type-size differs from that of the sink, but when
406+
; determining backward dependence, only the source size
407+
; is relevant.
408+
; TODO: Relax the HasSameSize check; this test should report
409+
; BackwardVectorizable.
410+
define void @different_type_sizes_source_size_backwardvectorizible(ptr %dst) {
411+
; CHECK-LABEL: 'different_type_sizes_source_size_backwardvectorizible'
412+
; CHECK-NEXT: loop:
413+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
414+
; CHECK-NEXT: Unknown data dependence.
415+
; CHECK-NEXT: Dependences:
416+
; CHECK-NEXT: Unknown:
417+
; CHECK-NEXT: store i16 0, ptr %gep.iv, align 2 ->
418+
; CHECK-NEXT: store i32 1, ptr %gep.10.iv, align 4
419+
; CHECK-EMPTY:
420+
; CHECK-NEXT: Run-time memory checks:
421+
; CHECK-NEXT: Grouped accesses:
422+
; CHECK-EMPTY:
423+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
424+
; CHECK-NEXT: SCEV assumptions:
425+
; CHECK-EMPTY:
426+
; CHECK-NEXT: Expressions re-written:
427+
;
428+
entry:
429+
%gep.10 = getelementptr nuw i8, ptr %dst, i64 10
430+
br label %loop
431+
432+
loop:
433+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
434+
%gep.iv = getelementptr i8, ptr %dst, i64 %iv
435+
store i16 0, ptr %gep.iv
436+
%gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
437+
store i32 1, ptr %gep.10.iv
438+
%iv.next = add i64 %iv, 8
439+
%ec = icmp eq i64 %iv.next, 64
440+
br i1 %ec, label %exit, label %loop
441+
442+
exit:
443+
ret void
444+
}
445+
446+
; Source type-size differs from that of the sink, and when
447+
; determining forward dependence, the source size can
448+
; prevent forwarding.
449+
define void @different_type_sizes_forward(ptr %dst) {
450+
; CHECK-LABEL: 'different_type_sizes_forward'
451+
; CHECK-NEXT: loop:
452+
; CHECK-NEXT: Memory dependences are safe
453+
; CHECK-NEXT: Dependences:
454+
; CHECK-NEXT: Forward:
455+
; CHECK-NEXT: store i32 0, ptr %gep.10.iv, align 4 ->
456+
; CHECK-NEXT: store i16 1, ptr %gep.iv, align 2
457+
; CHECK-EMPTY:
458+
; CHECK-NEXT: Run-time memory checks:
459+
; CHECK-NEXT: Grouped accesses:
460+
; CHECK-EMPTY:
461+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
462+
; CHECK-NEXT: SCEV assumptions:
463+
; CHECK-EMPTY:
464+
; CHECK-NEXT: Expressions re-written:
465+
;
466+
entry:
467+
%gep.10 = getelementptr nuw i8, ptr %dst, i64 10
468+
br label %loop
469+
470+
loop:
471+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
472+
%gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
473+
store i32 0, ptr %gep.10.iv
474+
%gep.iv = getelementptr i8, ptr %dst, i64 %iv
475+
store i16 1, ptr %gep.iv
476+
%iv.next = add i64 %iv, 8
477+
%ec = icmp eq i64 %iv.next, 64
478+
br i1 %ec, label %exit, label %loop
479+
480+
exit:
481+
ret void
482+
}
483+
484+
; Same as the above, but here, the store size should not prevent
485+
; ld->st forwarding.
486+
; TODO: Relax the HasSameSize check; this test should report a
487+
; forward dependence.
488+
define void @different_type_sizes_store_size_cannot_prevent_forwarding(ptr %A, ptr noalias %B) {
489+
; CHECK-LABEL: 'different_type_sizes_store_size_cannot_prevent_forwarding'
490+
; CHECK-NEXT: loop:
491+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
492+
; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
493+
; CHECK-NEXT: Dependences:
494+
; CHECK-NEXT: ForwardButPreventsForwarding:
495+
; CHECK-NEXT: store i32 0, ptr %gep.A, align 4 ->
496+
; CHECK-NEXT: %l = load i16, ptr %gep.A.1, align 2
497+
; CHECK-EMPTY:
498+
; CHECK-NEXT: Run-time memory checks:
499+
; CHECK-NEXT: Grouped accesses:
500+
; CHECK-EMPTY:
501+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
502+
; CHECK-NEXT: SCEV assumptions:
503+
; CHECK-EMPTY:
504+
; CHECK-NEXT: Expressions re-written:
505+
;
506+
entry:
507+
%A.1 = getelementptr i32, ptr %A, i64 1
508+
br label %loop
509+
510+
loop:
511+
%iv = phi i64 [ 1022, %entry ], [ %iv.next, %loop ]
512+
%gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
513+
store i32 0, ptr %gep.A
514+
%gep.A.1 = getelementptr i32, ptr %A.1, i64 %iv
515+
%l = load i16, ptr %gep.A.1
516+
store i16 %l, ptr %B
517+
%iv.next = add nsw i64 %iv, -1
518+
%cmp = icmp eq i64 %iv, 0
519+
br i1 %cmp, label %exit, label %loop
520+
521+
exit:
522+
ret void
523+
}
524+
525+
; Same as the above, but here, the load size prevents
526+
; ld->st forwarding.
527+
define void @different_type_sizes_load_size_prevents_forwarding(ptr %A, ptr noalias %B) {
528+
; CHECK-LABEL: 'different_type_sizes_load_size_prevents_forwarding'
529+
; CHECK-NEXT: loop:
530+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
531+
; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
532+
; CHECK-NEXT: Dependences:
533+
; CHECK-NEXT: ForwardButPreventsForwarding:
534+
; CHECK-NEXT: store i16 0, ptr %gep.A, align 2 ->
535+
; CHECK-NEXT: %l = load i32, ptr %gep.A.1, align 4
536+
; CHECK-EMPTY:
537+
; CHECK-NEXT: Run-time memory checks:
538+
; CHECK-NEXT: Grouped accesses:
539+
; CHECK-EMPTY:
540+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
541+
; CHECK-NEXT: SCEV assumptions:
542+
; CHECK-EMPTY:
543+
; CHECK-NEXT: Expressions re-written:
544+
;
545+
entry:
546+
%A.1 = getelementptr i32, ptr %A, i64 1
547+
br label %loop
548+
549+
loop:
550+
%iv = phi i64 [ 1022, %entry ], [ %iv.next, %loop ]
551+
%gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
552+
store i16 0, ptr %gep.A
553+
%gep.A.1 = getelementptr i32, ptr %A.1, i64 %iv
554+
%l = load i32, ptr %gep.A.1
555+
store i32 %l, ptr %B
556+
%iv.next = add nsw i64 %iv, -1
557+
%cmp = icmp eq i64 %iv, 0
558+
br i1 %cmp, label %exit, label %loop
559+
560+
exit:
561+
ret void
562+
}

0 commit comments

Comments
 (0)