[PATCH] D36808: [llvm.noalias] add llvm.noalias to pointer use visitor.

Ehsan Amiri via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 14:00:08 PDT 2017


amehsan created this revision.

This lets SROA (and pontentially other users of PtrUseVisitor) see through llvm.noalias intrinsic. Without this, SROA does misses some optimization opportunities because the pointers escapes through the intrinsic


https://reviews.llvm.org/D36808

Files:
  include/llvm/Analysis/PtrUseVisitor.h
  test/Transforms/SROA/noalias.ll


Index: test/Transforms/SROA/noalias.ll
===================================================================
--- /dev/null
+++ test/Transforms/SROA/noalias.ll
@@ -0,0 +1,34 @@
+; RUN: opt < %s -sroa -S | FileCheck %s
+define void @func1(i32 %a, i32* nocapture %c) local_unnamed_addr #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, i32* %a.addr, align 4, !tbaa !1
+  %0 = call i32* @llvm.noalias.p0i32(i32* %a.addr, metadata !5)
+  %1 = call i32* @llvm.noalias.p0i32(i32* %c, metadata !8)
+  %2 = load i32, i32* %0, align 4, !tbaa !1, !noalias !10
+  %sub.i = add nsw i32 %2, -1
+  store i32 %sub.i, i32* %1, align 4, !tbaa !1, !noalias !10
+  ret void
+; CHECK-LABEL: func1
+; CHECK-NOT: load
+}
+
+; Function Attrs: argmemonly nounwind
+declare i32* @llvm.noalias.p0i32(i32* returned, metadata) #1
+
+attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="hidspv100" "target-features"="+dsp-align,+support-FP,+support-VT" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { argmemonly nounwind }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 4.0.1 (git at code-sh.huawei.com:llvm-dsp/clang.git 9668a848677344729757118551803787ec9b2ddb) (git at code-sh.huawei.com:llvm-dsp/llvm-4.0.0.git 7e5546a857c742dc551afc4d294df7f285befcef)"}
+!1 = !{!2, !2, i64 0}
+!2 = !{!"int", !3, i64 0}
+!3 = !{!"omnipotent char", !4, i64 0}
+!4 = !{!"Simple C/C++ TBAA"}
+!5 = !{!6}
+!6 = distinct !{!6, !7, !"foo: %a"}
+!7 = distinct !{!7, !"foo"}
+!8 = !{!9}
+!9 = distinct !{!9, !7, !"foo: %b"}
+!10 = !{!6, !9}
Index: include/llvm/Analysis/PtrUseVisitor.h
===================================================================
--- include/llvm/Analysis/PtrUseVisitor.h
+++ include/llvm/Analysis/PtrUseVisitor.h
@@ -272,6 +272,9 @@
     case Intrinsic::lifetime_start:
     case Intrinsic::lifetime_end:
       return; // No-op intrinsics.
+    case Intrinsic::noalias:
+      enqueueUsers(II);
+      return;
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36808.111421.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170816/78446d8d/attachment.bin>


More information about the llvm-commits mailing list