From 0dd2b051236ff1d286c0e4368862ce4f3fd3880c Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 2 Oct 2021 18:07:16 -0700 Subject: qbe: Re-add conversion to bool RHS of logical and/or 7e838669 removed conversion to bool for int expressions used only to control jnz, but incorrectly dropped the conversion for the right-hand-side of logical and/or as well. We need the result of the expression to be 0 or 1, so we still need that conversion. --- test/logical-and.qbe | 27 +++++++++++++++------------ test/logical-or.qbe | 27 +++++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/logical-and.qbe b/test/logical-and.qbe index 21fd79a..b827bca 100644 --- a/test/logical-and.qbe +++ b/test/logical-and.qbe @@ -5,29 +5,32 @@ function w $main() { %.1 =w loadw $i jnz %.1, @logic_right.3, @logic_join.4 @logic_right.3 + %.2 =w cnew 1, 0 @logic_join.4 - %.2 =w phi @body.2 0, @logic_right.3 1 - jnz %.2, @if_true.5, @if_false.6 + %.3 =w phi @body.2 0, @logic_right.3 %.2 + jnz %.3, @if_true.5, @if_false.6 @if_true.5 ret 1 @if_false.6 - %.3 =s loads $f - %.4 =w cnes %.3, s_0 - jnz %.4, @logic_right.7, @logic_join.8 + %.4 =s loads $f + %.5 =w cnes %.4, s_0 + jnz %.5, @logic_right.7, @logic_join.8 @logic_right.7 + %.6 =w cnew 1, 0 @logic_join.8 - %.5 =w phi @if_false.6 0, @logic_right.7 1 - jnz %.5, @if_true.9, @if_false.10 + %.7 =w phi @if_false.6 0, @logic_right.7 %.6 + jnz %.7, @if_true.9, @if_false.10 @if_true.9 ret 1 @if_false.10 - %.6 =l loadl $p - %.7 =w cnel %.6, 0 - jnz %.7, @logic_right.11, @logic_join.12 + %.8 =l loadl $p + %.9 =w cnel %.8, 0 + jnz %.9, @logic_right.11, @logic_join.12 @logic_right.11 + %.10 =w cnew 1, 0 @logic_join.12 - %.8 =w phi @if_false.10 0, @logic_right.11 1 - jnz %.8, @if_true.13, @if_false.14 + %.11 =w phi @if_false.10 0, @logic_right.11 %.10 + jnz %.11, @if_true.13, @if_false.14 @if_true.13 ret 1 @if_false.14 diff --git a/test/logical-or.qbe b/test/logical-or.qbe index e1025c9..b66d0b6 100644 --- a/test/logical-or.qbe +++ b/test/logical-or.qbe @@ -5,29 +5,32 @@ function w $main() { %.1 =w loadw $i jnz %.1, @logic_join.4, @logic_right.3 @logic_right.3 + %.2 =w cnew 0, 0 @logic_join.4 - %.2 =w phi @body.2 1, @logic_right.3 0 - jnz %.2, @if_true.5, @if_false.6 + %.3 =w phi @body.2 1, @logic_right.3 %.2 + jnz %.3, @if_true.5, @if_false.6 @if_true.5 ret 1 @if_false.6 - %.3 =s loads $f - %.4 =w cnes %.3, s_0 - jnz %.4, @logic_join.8, @logic_right.7 + %.4 =s loads $f + %.5 =w cnes %.4, s_0 + jnz %.5, @logic_join.8, @logic_right.7 @logic_right.7 + %.6 =w cnew 0, 0 @logic_join.8 - %.5 =w phi @if_false.6 1, @logic_right.7 0 - jnz %.5, @if_true.9, @if_false.10 + %.7 =w phi @if_false.6 1, @logic_right.7 %.6 + jnz %.7, @if_true.9, @if_false.10 @if_true.9 ret 1 @if_false.10 - %.6 =l loadl $p - %.7 =w cnel %.6, 0 - jnz %.7, @logic_join.12, @logic_right.11 + %.8 =l loadl $p + %.9 =w cnel %.8, 0 + jnz %.9, @logic_join.12, @logic_right.11 @logic_right.11 + %.10 =w cnew 0, 0 @logic_join.12 - %.8 =w phi @if_false.10 1, @logic_right.11 0 - jnz %.8, @if_true.13, @if_false.14 + %.11 =w phi @if_false.10 1, @logic_right.11 %.10 + jnz %.11, @if_true.13, @if_false.14 @if_true.13 ret 1 @if_false.14 -- cgit v1.2.3