Subzero: Fix a bug in advanced phi lowering.
The motivating example (simplified) is this:
%__698:eax = phi i32 [ %__646:ebx, %__188 ] // LIVEEND={%__646:ebx}
%__617:bh = phi i8 [ %__618:ah, %__188 ] // LIVEEND={%__618:ah}
%__615:bl = phi i8 [ %__616:al, %__188 ] // LIVEEND={%__616:al}
By default, it first lowers the __698 assignment. However, that assignment has two "predecessors" because there are two other instructions whose dest variable aliases the __698 assignment's source operand. This triggers an assertion failure where we assume there is only one predecessor.
The fix is two-pronged. First, we go ahead and generate as many temp assignments as needed to break the cycle, simply by changing an "if" to a "while". Second, when we need to break a cycle, we give preference to an instruction with only one predecessor so that only one temp assignment needs to be added.
(It might be possible to prove that the second approach, i.e. preferring single-predecessor assignments, makes the first approach unnecessary, i.e. changing "if" to "while".)
This change has no effect on the x86 output for spec2k.
BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4365
R=jpp@chromium.org
Review URL: https://codereview.chromium.org/1839263003 .
Showing
Please
register
or
sign in
to comment