diff options
author | Michael Forney <mforney@mforney.org> | 2021-09-28 12:13:33 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-09-28 12:17:29 -0700 |
commit | 7e8386697aa60c1813019eda3cd2073e6be5b021 (patch) | |
tree | 14659072efa826982a43253af8cc3eb9b4c85381 /test/logical-or.qbe | |
parent | ab3946c6801be3520beeb79f5500ed1a944d4667 (diff) |
Skip unnecessary conversion to bool for logical and conditional expressions
As in ede6a5c9, if an expression is used only to control a jnz, we
don't need to convert it to a 0 or 1 value. QBE ignores the upper
32-bits of the argument to jnz, so the conversion is still needed
for pointer, long, and floating point types (including float since
-0 has non-zero bit representation).
Diffstat (limited to 'test/logical-or.qbe')
-rw-r--r-- | test/logical-or.qbe | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/logical-or.qbe b/test/logical-or.qbe new file mode 100644 index 0000000..e1025c9 --- /dev/null +++ b/test/logical-or.qbe @@ -0,0 +1,38 @@ +export +function w $main() { +@start.1 +@body.2 + %.1 =w loadw $i + jnz %.1, @logic_join.4, @logic_right.3 +@logic_right.3 +@logic_join.4 + %.2 =w phi @body.2 1, @logic_right.3 0 + jnz %.2, @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 +@logic_right.7 +@logic_join.8 + %.5 =w phi @if_false.6 1, @logic_right.7 0 + jnz %.5, @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 +@logic_right.11 +@logic_join.12 + %.8 =w phi @if_false.10 1, @logic_right.11 0 + jnz %.8, @if_true.13, @if_false.14 +@if_true.13 + ret 1 +@if_false.14 + ret 0 +} +export data $i = align 4 { z 4 } +export data $f = align 4 { z 4 } +export data $p = align 8 { z 8 } |