[llvm] ce3bb82 - [LICM] Add test for writeonly fn with noalias call.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 13:46:44 PDT 2022
Author: Florian Hahn
Date: 2022-04-22T21:37:08+01:00
New Revision: ce3bb82e4503fca385824f309f72444f6a960f37
URL: https://github.com/llvm/llvm-project/commit/ce3bb82e4503fca385824f309f72444f6a960f37
DIFF: https://github.com/llvm/llvm-project/commit/ce3bb82e4503fca385824f309f72444f6a960f37.diff
LOG: [LICM] Add test for writeonly fn with noalias call.
Add an additional test for D123473.
Added:
Modified:
llvm/test/Transforms/LICM/scalar-promote.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LICM/scalar-promote.ll b/llvm/test/Transforms/LICM/scalar-promote.ll
index 02fa9a5b3a151..d70a179c16da1 100644
--- a/llvm/test/Transforms/LICM/scalar-promote.ll
+++ b/llvm/test/Transforms/LICM/scalar-promote.ll
@@ -722,6 +722,48 @@ exit:
ret void
}
+declare dereferenceable(8) noalias i8* @alloc_writeonly() writeonly
+
+define void @test_sink_store_to_noalias_call_object_only_loop_may_not_execute1(i8 %n) writeonly {
+; CHECK: Function Attrs: writeonly
+; CHECK-LABEL: @test_sink_store_to_noalias_call_object_only_loop_may_not_execute1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[A:%.*]] = call noalias dereferenceable(8) i8* @alloc_writeonly()
+; CHECK-NEXT: [[A_PROMOTED:%.*]] = load i8, i8* [[A]], align 1
+; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
+; CHECK: loop.header:
+; CHECK-NEXT: [[DIV1:%.*]] = phi i8 [ [[A_PROMOTED]], [[ENTRY:%.*]] ], [ [[DIV:%.*]], [[LOOP_LATCH:%.*]] ]
+; CHECK-NEXT: [[I:%.*]] = phi i8 [ 0, [[ENTRY]] ], [ [[ADD:%.*]], [[LOOP_LATCH]] ]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[I]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[LOOP_LATCH]], label [[EXIT:%.*]]
+; CHECK: loop.latch:
+; CHECK-NEXT: [[DIV]] = sdiv i8 [[I]], 3
+; CHECK-NEXT: [[ADD]] = add i8 [[I]], 4
+; CHECK-NEXT: br label [[LOOP_HEADER]]
+; CHECK: exit:
+; CHECK-NEXT: [[DIV1_LCSSA:%.*]] = phi i8 [ [[DIV1]], [[LOOP_HEADER]] ]
+; CHECK-NEXT: store i8 [[DIV1_LCSSA]], i8* [[A]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ %a = call dereferenceable(8) noalias i8* @alloc_writeonly()
+ br label %loop.header
+
+loop.header:
+ %i = phi i8 [ 0, %entry ], [ %add, %loop.latch ]
+ %cmp = icmp ult i8 %i, %n
+ br i1 %cmp, label %loop.latch, label %exit
+
+loop.latch:
+ %div = sdiv i8 %i, 3
+ store i8 %div, i8* %a, align 1
+ %add = add i8 %i, 4
+ br label %loop.header
+
+exit:
+ ret void
+}
+
define void @test_sink_store_only_no_phi_needed() writeonly {
; CHECK: Function Attrs: writeonly
; CHECK-LABEL: @test_sink_store_only_no_phi_needed(
More information about the llvm-commits
mailing list