Commit graph

12 commits

Author SHA1 Message Date
Quentin Carbonneaux
3a3c88532c this can be false
I think I should check for Top when rewriting.
Because for sure, we don't want to replace some
temporary by Top, first, I can't represent it,
and second, it'd mean that it is a temporary
used undefined.

The example that triggered the assertion was like
that:

@b0
  jnz 1, @b1, @b3
@b1
  %x =w phi @b0 10, @b2 %x1
  jnz %x, @b2, @b3
@b2
  %x1 =w sub %x, 1
  jmp @b1
@b3
  %x2 =w phi @b1 %x, @b0 42

So SCCP optimistically assumes %x is 10 when it goes
through @b1, then at the branch, @b1->@b3 is left for
dead.  After that, @b2 is processed and the flow
worklist is empty.  Now uses are processed, %x2 will
get processed regardless if its block is dead or not
(it is at that time), then all the back-edges are dead
so the phi is set to the lattice merge of tops only.
BOOM!

This leads to the question, should phis of dead blocks
be processed?  I'll check that later.
2016-04-09 22:22:44 -04:00
Quentin Carbonneaux
d8770d112b fix wrong assertion in fold 2016-04-09 14:31:42 -04:00
Quentin Carbonneaux
71e6fa0b30 oops, forgot to patch phi arguments 2016-04-09 14:31:23 -04:00
Quentin Carbonneaux
a8fc696052 more debug tweaks in fold 2016-04-09 14:22:25 -04:00
Quentin Carbonneaux
1e0f18e908 add a proper block deletion routine 2016-04-09 14:21:56 -04:00
Quentin Carbonneaux
081360df6a nicer debug info 2016-04-09 09:38:20 -04:00
Quentin Carbonneaux
717524d4a3 quickly hack fold rewriting 2016-04-09 09:32:22 -04:00
Quentin Carbonneaux
554ba694ab use cast in czero() 2016-04-07 20:31:33 -04:00
Quentin Carbonneaux
9294295bb5 inline latmerge() (cross fingers) 2016-04-07 14:48:21 -04:00
Quentin Carbonneaux
03083f653d adjustments in sccp 2016-04-07 14:43:02 -04:00
Quentin Carbonneaux
ebcc123e4d add boring folding code 2016-04-07 13:21:15 -04:00
Quentin Carbonneaux
45f3493777 start work on constant propagation 2016-04-06 20:59:07 -04:00