Skip to content

Commit 3497a4f

Browse files
committed
[LICM] Add test to exercise assertion from D123473.
Add a test case that triggers an assertion with earlier versions of D123473.
1 parent 9ebbe25 commit 3497a4f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

llvm/test/Transforms/LICM/scalar-promote.ll

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,44 @@ Out:
599599

600600
}
601601

602+
define i8 @test_hoistable_existing_load_sinkable_store_writeonly(i8* dereferenceable(8) %ptr, i8 %start) writeonly {
603+
; CHECK: Function Attrs: writeonly
604+
; CHECK-LABEL: @test_hoistable_existing_load_sinkable_store_writeonly(
605+
; CHECK-NEXT: entry:
606+
; CHECK-NEXT: [[PTR_PROMOTED:%.*]] = load i8, i8* [[PTR:%.*]], align 1
607+
; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
608+
; CHECK: loop.header:
609+
; CHECK-NEXT: [[INC1:%.*]] = phi i8 [ [[PTR_PROMOTED]], [[ENTRY:%.*]] ], [ [[INC1]], [[LOOP_LATCH:%.*]] ]
610+
; CHECK-NEXT: [[I:%.*]] = phi i8 [ [[START:%.*]], [[ENTRY]] ], [ [[ADD:%.*]], [[LOOP_LATCH]] ]
611+
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[I]], 4
612+
; CHECK-NEXT: br i1 [[CMP]], label [[LOOP_LATCH]], label [[EXIT:%.*]]
613+
; CHECK: loop.latch:
614+
; CHECK-NEXT: store i8 [[INC1]], i8* [[PTR]], align 1
615+
; CHECK-NEXT: [[ADD]] = add i8 [[I]], [[INC1]]
616+
; CHECK-NEXT: br label [[LOOP_HEADER]]
617+
; CHECK: exit:
618+
; CHECK-NEXT: [[I_LCSSA:%.*]] = phi i8 [ [[I]], [[LOOP_HEADER]] ]
619+
; CHECK-NEXT: ret i8 [[I_LCSSA]]
620+
;
621+
entry:
622+
br label %loop.header
623+
624+
loop.header:
625+
%i = phi i8 [ %start, %entry ], [ %add, %loop.latch ]
626+
%cmp = icmp ult i8 %i, 4
627+
br i1 %cmp, label %loop.latch, label %exit
628+
629+
loop.latch:
630+
%div = sdiv i8 %i, 3
631+
%inc = load i8, i8* %ptr
632+
store i8 %inc, i8* %ptr
633+
%add = add i8 %i, %inc
634+
br label %loop.header
635+
636+
exit:
637+
ret i8 %i
638+
}
639+
602640
@glb = external global i8, align 1
603641

604642
; Test case for PR51248.

0 commit comments

Comments
 (0)