From ce0ab53ed73fb24f9537cab762467efad56f2664 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 6 Feb 2019 08:34:51 +0100 Subject: 2 bug fixes in rega The worst one was that "part 3" of rega() could break the critical invariant that two interferring temporaries get assigned different registers. This is fixed by being careful when changing the register of a temporary based on predecessor blocks. Thanks to Michael Forney for reporting these bugs and helping with the analysis. --- test/rega1.ssa | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/rega1.ssa (limited to 'test/rega1.ssa') diff --git a/test/rega1.ssa b/test/rega1.ssa new file mode 100644 index 0000000..9e87c89 --- /dev/null +++ b/test/rega1.ssa @@ -0,0 +1,24 @@ +# tests that %b and %a0 do not end up in +# the same register at the start of @loop + +export function l $f(l %a) { +@start +@loop + %b =l phi @start 42, @loop0 %a1, @loop1 %a1 + %a0 =l phi @start %a, @loop0 %a1, @loop1 %a1 + %a1 =l sub %a0, 1 + jnz %b, @loop0, @loop1 +@loop0 + jnz %a1, @loop, @end +@loop1 + jnz %a1, @loop, @end +@end + ret %b +} + +# >>> driver +# extern long long f(long long); +# int main() { +# return !(f(1) == 42 && f(2) == 1 && f(42) == 1); +# } +# <<< -- cgit 1.4.1