[PATCH] D50364: [LICM] Hoist assumes out of loops

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 10 15:22:31 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL339481: [LICM] Hoist assumes out of loops (authored by reames, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50364?vs=159549&id=160194#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50364

Files:
  llvm/trunk/lib/Transforms/Scalar/LICM.cpp
  llvm/trunk/test/Transforms/LICM/assume.ll


Index: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp
@@ -658,6 +658,15 @@
     if (CI->mayThrow())
       return false;
 
+    if (Function *F = CI->getCalledFunction())
+        switch (F->getIntrinsicID()) {
+        default: break;
+        // TODO: support invariant.start, and experimental.guard here
+        case Intrinsic::assume:
+          // Assumes don't actually alias anything or throw
+          return true;
+        };
+    
     // Handle simple cases by querying alias analysis.
     FunctionModRefBehavior Behavior = AA->getModRefBehavior(CI);
     if (Behavior == FMRB_DoesNotAccessMemory)
Index: llvm/trunk/test/Transforms/LICM/assume.ll
===================================================================
--- llvm/trunk/test/Transforms/LICM/assume.ll
+++ llvm/trunk/test/Transforms/LICM/assume.ll
@@ -36,9 +36,9 @@
 define void @f_1(i1 %cond, i32* %ptr) {
 ; CHECK-LABEL: @f_1(
 ; CHECK-LABEL: entry:
+; CHECK: call void @llvm.assume(i1 %cond)
 ; CHECK: %val = load i32, i32* %ptr
 ; CHECK-LABEL: loop:
-; CHECK: call void @llvm.assume(i1 %cond)
 
 entry:
   br label %loop


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50364.160194.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180810/5819d626/attachment.bin>


More information about the llvm-commits mailing list