[llvm] [polly] [AST] Don't merge memory locations in AliasSetTracker (PR #65731)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 08:18:51 PST 2023


================
@@ -0,0 +1,66 @@
+; RUN: opt < %s -passes=aa-eval -evaluate-aa-metadata -aa-pipeline=basic-aa,tbaa -print-all-alias-modref-info -disable-output 2>&1 | FileCheck --check-prefix=CHECKAA %s
+; RUN: opt < %s -S -passes=licm | FileCheck --check-prefix=CHECKLICM %s
+
+; See https://discourse.llvm.org/t/rfc-dont-merge-memory-locations-in-aliassettracker/73336
+; pairwise TBAA indicates NoAlias of load/store ptr at %s with store i32 at %0
+; yet LICM fails to promote load/store ptr %s out of the loop
+
+target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
+
+; CHECKAA-LABEL: Function: _Z4testP1S: 2 pointers, 0 call sites
+; CHECKAA-DAG:  NoAlias:   %0 = load ptr, ptr %s, align 4, !tbaa !7 <->   store i32 %i.05, ptr %0, align 4, !tbaa !12
+; CHECKAA-DAG:  MustAlias:   %0 = load ptr, ptr %s, align 4, !tbaa !7 <->   store ptr %add.ptr.i, ptr %s, align 4, !tbaa !14
+; CHECKAA-DAG:  NoAlias:   store ptr %add.ptr.i, ptr %s, align 4, !tbaa !14 <->   store i32 %i.05, ptr %0, align 4, !tbaa !12
+
+; CHECKLICM-LABEL: define void @_Z4testP1S(ptr noundef %s)
+; CHECKLICM: entry:
+; CHECKLICM: [[P_ENTRY:%[^ ]+]] = load ptr, ptr %s
+; CHECKLICM: for.cond.cleanup:
+; CHECKLICM: [[P_DONE:%[^ ]+]] = phi ptr [ [[P_NEXT:%[^ ]+]], %for.body ]
+; CHECKLICM: store ptr [[P_DONE]], ptr %s
+; CHECKLICM: for.body:
+; CHECKLICM: [[P:%[^ ]+]] = phi ptr [ [[P_ENTRY]], %entry ], [ [[P_NEXT]], %for.body ]
+; CHECKLICM: store i32 {{%[^ ]+}}, ptr [[P]]
+; CHECKLICM: [[P_NEXT]] = getelementptr inbounds i32, ptr [[P]], i32 1
+
+define void @_Z4testP1S(ptr noundef %s) #0 {
+entry:
+  br label %for.body
+
+for.cond.cleanup:                                 ; preds = %for.body
+  ret void
+
+for.body:                                         ; preds = %entry, %for.body
+  %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+  %0 = load ptr, ptr %s, align 4, !tbaa !7
+  store i32 %i.05, ptr %0, align 4, !tbaa !12
+  %add.ptr.i = getelementptr inbounds i32, ptr %0, i32 1
+  store ptr %add.ptr.i, ptr %s, align 4, !tbaa !14
+  %inc = add nuw nsw i32 %i.05, 1
+  %exitcond.not = icmp eq i32 %inc, 100
+  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !15
+}
+
+attributes #0 = { mustprogress }
+
+!llvm.module.flags = !{!0, !1, !2, !3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = !{i32 1, !"NumRegisterParameters", i32 0}
+!1 = !{i32 7, !"Dwarf Version", i32 4}
+!2 = !{i32 1, !"wchar_size", i32 4}
+!3 = !{i32 8, !"PIC Level", i32 2}
+!4 = !{i32 7, !"PIE Level", i32 2}
+!5 = !{i32 7, !"uwtable", i32 2}
+!6 = !{!"clang version 18.0.0 (https://github.com/llvm/llvm-project.git 2cab996192cf143d10e3381fcefa75e270cc7ddb)"}
+!7 = !{!8, !9, i64 0}
+!8 = !{!"_ZTS1S", !9, i64 0}
+!9 = !{!"any pointer", !10, i64 0}
+!10 = !{!"omnipotent char", !11, i64 0}
+!11 = !{!"Simple C++ TBAA"}
+!12 = !{!13, !13, i64 0}
+!13 = !{!"int", !10, i64 0}
+!14 = !{!9, !9, i64 0}
+!15 = distinct !{!15, !16, !17}
+!16 = !{!"llvm.loop.mustprogress"}
+!17 = !{!"llvm.loop.unroll.disable"}
----------------
nikic wrote:

Remove all unnecessary metadata. Only keep the tbaa metadata.

https://github.com/llvm/llvm-project/pull/65731


More information about the llvm-commits mailing list