[PATCH] D124368: [LoopInstSimplify] Ignore users in unreachable blocks. PR55072

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 03:36:08 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG606a000d1a13: [LoopInstSimplify] Ignore users in unreachable blocks. PR55072 (authored by mkazantsev).

Changed prior to commit:
  https://reviews.llvm.org/D124368?vs=424847&id=424858#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124368

Files:
  llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
  llvm/test/Transforms/LoopInstSimplify/pr55072.ll


Index: llvm/test/Transforms/LoopInstSimplify/pr55072.ll
===================================================================
--- llvm/test/Transforms/LoopInstSimplify/pr55072.ll
+++ llvm/test/Transforms/LoopInstSimplify/pr55072.ll
@@ -1,11 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S %s -passes=loop-instsimplify | FileCheck %s
 ; RUN: opt -S %s -passes='loop-mssa(loop-instsimplify)' -verify-memoryssa | FileCheck %s
 
-; XFAIL: *
-; REQUIRES: asserts
-
 define i32 @test_01() {
-; CHECK-LABEL: test_01
+; CHECK-LABEL: @test_01(
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    br label [[LOOP]]
+; CHECK:       unreached:
+; CHECK-NEXT:    ret i32 0
+;
 bb:
   br label %loop
 
Index: llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
+++ llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
@@ -104,6 +104,10 @@
           auto *UserI = cast<Instruction>(U.getUser());
           U.set(V);
 
+          // Do not bother dealing with unreachable code.
+          if (!DT.isReachableFromEntry(UserI->getParent()))
+            continue;
+
           // If the instruction is used by a PHI node we have already processed
           // we'll need to iterate on the loop body to converge, so add it to
           // the next set.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124368.424858.patch
Type: text/x-patch
Size: 1446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220425/c15a8f76/attachment-0001.bin>


More information about the llvm-commits mailing list