[PATCH] D68495: [PATCH 12/38] [noalias] EarlyCSE: learn about noalias intrinsics

Jeroen Dobbelaere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 14:40:17 PDT 2019


jeroen.dobbelaere created this revision.
jeroen.dobbelaere added reviewers: hfinkel, jdoerfert.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This is part of the series started by D68484 <https://reviews.llvm.org/D68484>.

Note: this is a stable point and tests should run fine with the patches applied up to this point.


https://reviews.llvm.org/D68495

Files:
  llvm/lib/Transforms/Scalar/EarlyCSE.cpp
  llvm/test/Transforms/EarlyCSE/basic.ll


Index: llvm/test/Transforms/EarlyCSE/basic.ll
===================================================================
--- llvm/test/Transforms/EarlyCSE/basic.ll
+++ llvm/test/Transforms/EarlyCSE/basic.ll
@@ -57,7 +57,17 @@
 ; CHECK-LABEL: @test2b(
 define i32 @test2b(i32 *%P, i1 %b) {
   %V1 = load i32, i32* %P
-  call i8* @llvm.noalias.p0i8(i8* undef, metadata !1)
+  call i8* @llvm.noalias.p0i8.p0i8.p0p0i8.i32(i8* undef, i8* null, i8** null, i32 0, metadata !1)
+  %V2 = load i32, i32* %P
+  %Diff = sub i32 %V1, %V2
+  ret i32 %Diff
+  ; CHECK: ret i32 0
+}
+
+; CHECK-LABEL: @test2c(
+define i32 @test2c(i32 *%P, i1 %b) {
+  %V1 = load i32, i32* %P
+  call i8* @llvm.side.noalias.p0i8.p0i8.p0p0i8.p0p0i8.i32(i8* undef, i8* null, i8** null, i8** null, i32 0, metadata !1)
   %V2 = load i32, i32* %P
   %Diff = sub i32 %V1, %V2
   ret i32 %Diff
@@ -147,7 +157,16 @@
 ; CHECK-LABEL: @test6b(
 define i32 @test6b(i32 *%P, i1 %b) {
   store i32 42, i32* %P
-  call i8* @llvm.noalias.p0i8(i8* undef, metadata !1)
+  call i8* @llvm.noalias.p0i8.p0i8.p0p0i8.i32(i8* undef, i8* null, i8** null, i32 0, metadata !1)
+  %V1 = load i32, i32* %P
+  ret i32 %V1
+  ; CHECK: ret i32 42
+}
+
+; CHECK-LABEL: @test6c(
+define i32 @test6c(i32 *%P, i1 %b) {
+  store i32 42, i32* %P
+  call i8* @llvm.side.noalias.p0i8.p0i8.p0p0i8.p0p0i8.i32(i8* undef, i8* null, i8** null, i8** null, i32 0, metadata !1)
   %V1 = load i32, i32* %P
   ret i32 %V1
   ; CHECK: ret i32 42
@@ -311,7 +330,8 @@
   ret void
 }
 
-declare i8* @llvm.noalias.p0i8(i8*, metadata) nounwind
+declare i8*  @llvm.noalias.p0i8.p0i8.p0p0i8.i32(i8*, i8*, i8**, i32, metadata ) nounwind
+declare i8*  @llvm.side.noalias.p0i8.p0i8.p0p0i8.p0p0i8.i32(i8*, i8*, i8**, i8**, i32, metadata ) nounwind
 
 !0 = !{!0, !"some domain"}
 !1 = !{!1, !0, !"some scope"}
Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -927,18 +927,25 @@
                           << '\n');
         AvailableValues.insert(CondI, ConstantInt::getTrue(BB->getContext()));
       } else
-        LLVM_DEBUG(dbgs() << "EarlyCSE skipping assumption: " << *Inst << '\n');
+        LLVM_DEBUG(dbgs() << "EarlyCSE skipping intrinsic: " << *Inst << '\n');
       continue;
     }
 
-    // Skip sideeffect intrinsics, for the same reason as assume intrinsics.
     // Likewise, noalias intrinsics don't actually write.
-    if (match(Inst, m_CombineOr(m_Intrinsic<Intrinsic::sideeffect>(),
-                                m_Intrinsic<Intrinsic::assume>()))) {
+    if (match(Inst, m_Intrinsic<Intrinsic::noalias>()) ||
+        match(Inst, m_Intrinsic<Intrinsic::noalias_decl>()) ||
+        match(Inst, m_Intrinsic<Intrinsic::side_noalias>()) ||
+        match(Inst, m_Intrinsic<Intrinsic::noalias_arg_guard>())) {
       LLVM_DEBUG(dbgs() << "EarlyCSE skipping intrinsic: " << *Inst << '\n');
       continue;
     }
 
+    // Skip sideeffect intrinsics, for the same reason as assume intrinsics.
+    if (match(Inst, m_Intrinsic<Intrinsic::sideeffect>())) {
+      LLVM_DEBUG(dbgs() << "EarlyCSE skipping sideeffect: " << *Inst << '\n');
+      continue;
+    }
+
     // We can skip all invariant.start intrinsics since they only read memory,
     // and we can forward values across it. For invariant starts without
     // invariant ends, we can use the fact that the invariantness never ends to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68495.223295.patch
Type: text/x-patch
Size: 3472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/e70bf4e2/attachment.bin>


More information about the llvm-commits mailing list