Index: llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp +++ llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp @@ -535,6 +535,11 @@ return false; } + if (!L->isLoopSimplifyForm()) { + LLVM_DEBUG(dbgs() << "Loop is not is loop-simplify form"); + return false; + } + if (!Checks.empty() || !LAI.getPSE().getUnionPredicate().isAlwaysTrue()) { if (LAI.hasConvergentOp()) { LLVM_DEBUG(dbgs() << "Versioning is needed but not allowed with " @@ -554,11 +559,6 @@ return false; } - if (!L->isLoopSimplifyForm()) { - LLVM_DEBUG(dbgs() << "Loop is not is loop-simplify form"); - return false; - } - // Point of no-return, start the transformation. First, version the loop // if necessary. Index: llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll =================================================================== --- llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll +++ llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll @@ -1,7 +1,5 @@ -; XFAIL: * ; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s -; This test demonstrates an assertion failure due to missing preheader in new PM. -; REQUIRES: asserts +; Make sure it doesn't crash in new pass manager due to missing preheader. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" define void @test(i32* noalias nocapture %A, i32* noalias nocapture readonly %B, i64 %N, i1 %C) {