[PATCH] D111098: [LICM] Bail if checking a global/constant for invariant.start

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 4 14:14:33 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f28b4d5b7a5: [LICM] Bail if checking a global/constant for invariant.start (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111098/new/

https://reviews.llvm.org/D111098

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


Index: llvm/test/Transforms/LICM/hoisting.ll
===================================================================
--- llvm/test/Transforms/LICM/hoisting.ll
+++ llvm/test/Transforms/LICM/hoisting.ll
@@ -602,16 +602,16 @@
 
 @a = external global i8
 
-; FIXME: Don't hoist invariant loads of globals.
+; FIXME: Support hoisting invariant loads of globals.
 define void @test_fence6() {
 ; CHECK-LABEL: @test_fence6(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[I:%.*]] = call {}* @llvm.invariant.start.p0i8(i64 1, i8* @a)
+; CHECK-NEXT:    br label [[F:%.*]]
+; CHECK:       f:
 ; CHECK-NEXT:    [[TMP0:%.*]] = load i8, i8* @a, align 1
 ; CHECK-NEXT:    [[TMP1:%.*]] = and i8 [[TMP0]], 0
 ; CHECK-NEXT:    [[T:%.*]] = icmp eq i8 [[TMP1]], 0
-; CHECK-NEXT:    br label [[F:%.*]]
-; CHECK:       f:
 ; CHECK-NEXT:    tail call void @g(i1 [[T]])
 ; CHECK-NEXT:    br label [[F]]
 ;
Index: llvm/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LICM.cpp
+++ llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1068,6 +1068,10 @@
       return false;
     Addr = BC->getOperand(0);
   }
+  // If we've ended up at a global/constant, bail. We shouldn't be looking at
+  // uselists for non-local Values in a loop pass.
+  if (isa<Constant>(Addr))
+    return false;
 
   unsigned UsesVisited = 0;
   // Traverse all uses of the load operand value, to see if invariant.start is


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111098.377035.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211004/8a4d1507/attachment.bin>


More information about the llvm-commits mailing list