<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60262>60262</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Simplify flow conditions in join operation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:dataflow
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ymand
</td>
</tr>
</table>
<pre>
When a join is performed at a loop head, the resulting flow condition will naively grow redundant clauses with each iteration over the loop.
Assuming we enter a loop with `FC1` and then add `FC2` during analysis of the body, we end with `FC1 and FC2`. Currently, the join will produce `FC1 or (FC1 and FC2)`. This is inefficient, so we should start by fixing the FC join operation to avoid situations like this and eagerly simplify to `FC1`.
There may be situations involving gotos that could look quite different, namely the loop body would end with `D` and the join therefore is `C` or `D` with no commonality. Moreover, another time through the loop will result in first `D or (C or D)` (after the join from the goto, assuming no further conditions are accumulated in the loop body) and then `C or (D or (C or D))` when we join before the loop head. So, that indicates a need for further simplification of disjunctions. The case where the body adds conditions is a little more complicated, but similarly results in a stable value, if simplifications are applied.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxkVM2O4zgPfBrlQkzgKH9fDj70l0Zue5oB9kxbVMweWcrqJ1m__YKy053evSSwIFYViyViSnz1RK3a_1_t31dY8hBiO43ozaoLZmr_HMgDwkdgD5zgRtGGOJIBzIDgQrjBQGiUPkMeCCKl4jL7K1gXHtAHbzhz8PBg58Aj38lNcI3hAZFM8QZ9ht5hSZTgwXkAwn4AzhSx1oU7xYosVGvVvKvmbf59S6mMwvQgIJ8pPvVUGHVoLueNOjSA3giABzRmPtZybEqUYvTopsQJgq000rQ0U0HNK1YFmovXcC4xks9uejZeDapN3mIwpadnVYig9P9e6_WpQvwaOIml7Mla7pl8FrAUhDsNoTgDKWPM0E1g-W9RK0yX80wWbk-PcgC8BzaQOJd6lMDxb4IsFEJLeKXoJkg83hzbSUo-Hfrm6q-BIsGI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