<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55697>55697</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            "LLVM ERROR: Broken module found, compilation aborted!" after SimpleLoopUnswitchPass
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mikaelholmen
      </td>
    </tr>
</table>

<pre>
    llvm commit: 0d7f8d42fd1
Reproduce with:
```
opt -passes="loop-mssa(simple-loop-unswitch<nontrivial>)" bbi-70146.ll -o /dev/null
```
[bbi-70146.ll.gz](https://github.com/llvm/llvm-project/files/8771344/bbi-70146.ll.gz)

Result:
```
Instruction does not dominate all uses!
  %spec.select = select i1 false, i1 true, i1 false
  br i1 %spec.select, label %entry.split.us, label %entry.split
LLVM ERROR: Broken module found, compilation aborted!
```
With -debug-pass-manager we see this happens after SimpleLoopUnswitchPass:
```
Running pass: VerifierPass on [module]
Running analysis: VerifierAnalysis on [module]
Running analysis: InnerAnalysisManagerProxy<llvm::FunctionAnalysisManager, llvm::Module> on [module]
Running analysis: PreservedCFGCheckerAnalysis on main
Running pass: LoopSimplifyPass on main
Running analysis: LoopAnalysis on main
Running analysis: DominatorTreeAnalysis on main
Running analysis: AssumptionAnalysis on main
Running analysis: TargetIRAnalysis on main
Running pass: LCSSAPass on main
Running analysis: MemorySSAAnalysis on main
Running analysis: AAManager on main
Running analysis: TargetLibraryAnalysis on main
Running analysis: BasicAA on main
Running analysis: ScopedNoAliasAA on main
Running analysis: TypeBasedAA on main
Running analysis: OuterAnalysisManagerProxy<llvm::ModuleAnalysisManager, llvm::Function> on main
Running analysis: ScalarEvolutionAnalysis on main
Running analysis: InnerAnalysisManagerProxy<llvm::LoopAnalysisManager, llvm::Function> on main
Running pass: SimpleLoopUnswitchPass on Loop at depth 1 containing: %for.cond142<header><latch><exiting>
Clearing all analysis results for: for.cond142
Running pass: SimpleLoopUnswitchPass on Loop at depth 1 containing: %for.cond142.us<header><latch>
Invalidating analysis: PreservedCFGCheckerAnalysis on main
Invalidating analysis: VerifierAnalysis on [module]
Running pass: VerifierPass on [module]
Running analysis: VerifierAnalysis on [module]
Instruction does not dominate all uses!
  %spec.select = select i1 false, i1 true, i1 false
  br i1 %spec.select, label %entry.split.us, label %entry.split
LLVM ERROR: Broken module found, compilation aborted!
```
This starts happening with commit 41e142fdc797
```
Recommit "[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both."

This reverts commit 7211d5ce07830ebfa2cfc30818cd7155375f7e47.

This version fixes a crash that caused buildbot failures with the first
version.
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV01v4zYQ_TXyhbAgUZZlH3xwnKQIkGwCJ92eKXFks6FIgaScuL--Q0rZdb6dLdpTAdmmqJnhm8cnzrjUfL-QcteQSjeNcFG2JAkv6hmf0JqnUXIaJcs1tEbzrgLyINwWTfrpaJoMV7jVrSPjllkLNspOI0ql1u24sZZFdGZF00oYh6lOWYxTYaCV0soZsRNMRtlZROfoRcpSjIsknUxjKclYk4iec9jht-qkfHPlKD85dIo3f0U5AphtnWuth0vP8dog9q6MMU-88SkPP2NM7k-oHN7WQiJ4ej4rijSbTHD0Mi5C7JcciLGddO8RcqGsM13lhFaEa7BEaYeDRijmgDDMrvNc0YFlgpnmtoUqtiARD0EWyTAUKamZtBDRlR9j2KdhPz0EKI2feh7G20lWgvTzgHTvY9tK4eLOvveoD3d5-f2KnK3X12svihOj70GRBnUggdS6U9y7I5utkCzkyEptHPAfCb2g4w_kn4w5lN0myGTcMMU2YMgDYJpA3FZYsmVtC8oSVjt8chtUc4mi-X3QzA06vsf3ulNKqA1pexvyHYyoBRjvQxAfyqSH79XxzAOByL0Vz7yWw9zxnhdK_XS76pO7Mfpxj0IPekPc2fK8U0ESLwzDXvwwuupXy86OX_3GgAWzA746_221her-eQ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