[PATCH] llvm.noalias - isObjectSizeLessThanOrEq in InstCombine should look through them

hfinkel at anl.gov hfinkel at anl.gov
Thu Apr 30 09:09:53 PDT 2015


Hi chandlerc, reames,

This is part of the series started by D9375, and teaches isObjectSizeLessThanOrEq in InstCombine to look through the calls to llvm.noalias.

http://reviews.llvm.org/D9395

Files:
  lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  test/Transforms/InstCombine/mem-gep-zidx.ll

Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -508,7 +508,7 @@
 
   do {
     Value *P = Worklist.pop_back_val();
-    P = P->stripPointerCasts();
+    P = P->stripPointerCasts(/*LookThroughNoAlias*/true);
 
     if (!Visited.insert(P).second)
       continue;
Index: test/Transforms/InstCombine/mem-gep-zidx.ll
===================================================================
--- test/Transforms/InstCombine/mem-gep-zidx.ll
+++ test/Transforms/InstCombine/mem-gep-zidx.ll
@@ -32,6 +32,22 @@
 ; CHECK: ret void
 }
 
+define void @test2a(i32 signext %x, i64 %v) #0 {
+entry:
+  %p = alloca i64
+  %pa = call i64* @llvm.noalias.p0i64(i64* %p, metadata !1)
+  %idxprom = sext i32 %x to i64
+  %arrayidx = getelementptr inbounds i64, i64* %pa, i64 %idxprom
+  store i64 %v, i64* %arrayidx
+  call void @foo(i64* %pa)
+  ret void
+
+; CHECK-LABEL: @test2a
+; CHECK: %p = alloca i64
+; CHECK: store i64 %v, i64* %pa
+; CHECK: ret void
+}
+
 define signext i32 @test3(i32 signext %x, i1 %y) #0 {
 entry:
   %idxprom = sext i32 %x to i64
@@ -46,3 +62,8 @@
 
 attributes #0 = { nounwind readnone }
 
+declare i64* @llvm.noalias.p0i64(i64*, metadata) nounwind
+
+!0 = !{!0, !"some domain"}
+!1 = !{!1, !0, !"some scope"}
+

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9395.24733.patch
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150430/75778473/attachment.bin>


More information about the llvm-commits mailing list