From 82c3de3ad2316211a79c6beda90bbe4f1e511ede Mon Sep 17 00:00:00 2001
From: Tristan Menzel <tristanmenzel@gmail.com>
Date: Wed, 30 Oct 2024 12:46:15 -0700
Subject: [PATCH] refactor: Use BoolConstant for constant arc4 boolean values

---
 examples/sizes.txt                            | 34 +++++++++----------
 src/puya/awst/nodes.py                        |  5 ++-
 src/puya/ir/builder/main.py                   | 21 ++++++++++--
 src/puyapy/awst_build/eb/arc4/bool.py         | 19 ++++++-----
 .../out/Arc4BoolEvalContract.ssa.ir           |  3 +-
 .../Arc4BoolEvalContract.ssa.opt_pass_1.ir    |  3 +-
 test_cases/arc4_types/out/module.awst         |  2 +-
 .../Arc4BoolEvalContract.approval.teal        |  3 --
 .../Arc4BoolEvalContract.destructured.ir      |  3 +-
 test_cases/arc4_types/puya.log                |  2 --
 test_cases/typed_abi_call/out/Greeter.ssa.ir  |  3 +-
 .../out/Greeter.ssa.opt_pass_1.ir             |  3 +-
 test_cases/typed_abi_call/out/module.awst     |  2 +-
 .../out_unoptimized/Greeter.approval.teal     |  5 +--
 .../out_unoptimized/Greeter.destructured.ir   |  4 +--
 test_cases/typed_abi_call/puya.log            |  5 +--
 16 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/examples/sizes.txt b/examples/sizes.txt
index 2fcbd621de..e391cbcbf9 100644
--- a/examples/sizes.txt
+++ b/examples/sizes.txt
@@ -4,22 +4,22 @@
  abi_routing/Reference                         1440    1216       -    |        794     623       - 
  amm/ConstantProductAMM                        1225    1106       -    |        715     645       - 
  application/Reference                          177     167       -    |         92      83       - 
- arc4_dynamic_arrays/DynamicArray              2695    1931       -    |       1733    1138       - 
+ arc4_dynamic_arrays/DynamicArray              2674    1931       -    |       1718    1138       - 
  arc4_numeric_comparisons/UIntNOrdering        1100     908       -    |        786     597       - 
  arc4_types/Arc4Address                          85      62       -    |         37      18       - 
- arc4_types/Arc4Arrays                          623     376       -    |        368     182       - 
- arc4_types/Arc4BoolEval                        751      14       -    |        167       8       - 
+ arc4_types/Arc4Arrays                          584     376       -    |        337     182       - 
+ arc4_types/Arc4BoolEval                        733      14       -    |        154       8       - 
  arc4_types/Arc4BoolType                        381      69       -    |        307      46       - 
  arc4_types/Arc4DynamicBytes                    377     185       -    |        213     100       - 
- arc4_types/Arc4DynamicStringArray              283     124       -    |        172      53       - 
- arc4_types/Arc4MutableParams                   471     286       -    |        292     141       - 
- arc4_types/Arc4Mutation                       2958    1426       -    |       1977     593       - 
+ arc4_types/Arc4DynamicStringArray              263     124       -    |        152      53       - 
+ arc4_types/Arc4MutableParams                   431     286       -    |        262     141       - 
+ arc4_types/Arc4Mutation                       2782    1426       -    |       1867     593       - 
  arc4_types/Arc4NumericTypes                    749     186       -    |        243      26       - 
  arc4_types/Arc4RefTypes                         85      46       -    |         32      27       - 
- arc4_types/Arc4StringTypes                     455      35       -    |        245      13       - 
+ arc4_types/Arc4StringTypes                     349      35       -    |        149      13       - 
  arc4_types/Arc4StructsFromAnotherModule         67      12       -    |         49       6       - 
  arc4_types/Arc4StructsType                     302     239       -    |        204     121       - 
- arc4_types/Arc4TuplesType                      795     136       -    |        537      58       - 
+ arc4_types/Arc4TuplesType                      781     136       -    |        524      58       - 
  arc_28/EventEmitter                            186     133       -    |        100      64       - 
  asset/Reference                                268     261       -    |        144     141       - 
  auction/Auction                                592     522       -    |        328     281       - 
@@ -27,7 +27,7 @@
  avm_types_in_abi/Test                          386     317       -    |        237     178       - 
  biguint_binary_ops/BiguintBinaryOps            186      77       -    |        100      20       - 
  boolean_binary_ops/BooleanBinaryOps           1124     471       -    |        680     258       - 
- box_storage/Box                               1765    1423       -    |       1154     873       - 
+ box_storage/Box                               1749    1423       -    |       1137     873       - 
  bug_load_store_load_store                       78      72       -    |         39      35       - 
  bytes_ops/BiguintBinaryOps                     139       -       -    |         82       -       - 
  calculator                                     334     317     315    |        182     168     166 
@@ -35,7 +35,7 @@
  chained_assignment/ChainedAssignment            87      87       -    |         30      29       - 
  compile/Hello                                  217     181       -    |        107      85       - 
  compile/HelloBase                              198     156       -    |         98      75       - 
- compile/HelloFactory                          7401    6824       -    |       1115     842       - 
+ compile/HelloFactory                          7284    6824       -    |       1025     842       - 
  compile/HelloOtherConstants                    306     281       -    |        137     121       - 
  compile/HelloPrfx                              211     168       -    |        102      77       - 
  compile/HelloTmpl                              211     168       -    |        102      77       - 
@@ -46,7 +46,7 @@
  conditional_expressions/Literals                84      49       -    |         61      30       - 
  constants/AddressConstant                       65      47       -    |         23       9       - 
  constants/ByteConstants                         92      76       -    |         23       9       - 
- contains                                      1682    1623       -    |        849     787       - 
+ contains                                      1680    1623       -    |        839     787       - 
  control_op_simplification                       48      44      37    |         23      18      15 
  debug/Debug                                    470     428       -    |        261     236       - 
  diamond_mro/Base1                              176     156       -    |         64      52       - 
@@ -56,7 +56,7 @@
  dup2_optimization_bug                           25      22       -    |         16      14       - 
  edverify/Verify                                 39      26       -    |         21      14       - 
  enumeration/Enumeration                        513     476       -    |        252     232       - 
- everything                                     524     459       -    |        247     205       - 
+ everything                                     505     459       -    |        232     205       - 
  global_state/AppState                          467     463       -    |        194     190       - 
  group_side_effects/AppCall                     106      82       -    |         55      42       - 
  group_side_effects/AppExpectingEffects         263     215       -    |        155     125       - 
@@ -93,7 +93,7 @@
  module_consts                                   52      50       -    |         12      11       - 
  named_tuples/NamedTuples                       397     328       -    |        225     171       - 
  nested_loops/Nested                            213     200       -    |        132     120       - 
- regression_tests/Issue118                      167     111       -    |         95      57       - 
+ regression_tests/Issue118                      152     111       -    |         83      57       - 
  regression_tests/Issue194                       34      22       -    |         22      11       - 
  reinterpret_cast                               151     119       -    |         78      58       - 
  scratch_slots                                   94      84       -    |         56      43       - 
@@ -103,7 +103,7 @@
  simplish/Simplish                              742     714     715    |        254     231     230 
  ssa                                            267     225       -    |        158     129       - 
  ssa2                                            92      84       -    |         53      43       - 
- state_mutations                               1165     848       -    |        754     528       - 
+ state_mutations                               1124     848       -    |        724     528       - 
  state_proxies/StateProxy                       129     117       -    |         59      51       - 
  state_totals                                    65      32       -    |         32      16       - 
  stress_tests/BruteForceRotationSearch          228     163       -    |        152     106       - 
@@ -120,8 +120,8 @@
  tuple_support/NestedTuples                    1259     900     897    |        784     510     509 
  tuple_support/TupleComparisons                 124      67       -    |         81      35       - 
  tuple_support/TupleSupport                     667     405       -    |        375     175       - 
- typed_abi_call/Greeter                        5040    3977    3968    |       2727    1832    1829 
- typed_abi_call/Logger                         1405    1144    1141    |        822     603     602 
+ typed_abi_call/Greeter                        4787    3977    3968    |       2510    1832    1829 
+ typed_abi_call/Logger                         1402    1144    1141    |        812     603     602 
  typed_abi_call_txn/Caller                      580     514       -    |        306     263       - 
  typed_abi_call_txn/Txn                         310     248       -    |        172     134       - 
  unary/Unary                                    126      67       -    |         62      28       - 
@@ -130,4 +130,4 @@
  unssa/UnSSA                                    432     368       -    |        241     204       - 
  voting/VotingRoundApp                         1593    1483       -    |        734     649       - 
  with_reentrancy/WithReentrancy                 255     242       -    |        132     122       - 
- Total                                        69200   53576   53517    |      32843   21764   21720 
\ No newline at end of file
+ Total                                        68300   53576   53517    |      32114   21764   21720 
\ No newline at end of file
diff --git a/src/puya/awst/nodes.py b/src/puya/awst/nodes.py
index 7b35ab436f..4ba14ed54f 100644
--- a/src/puya/awst/nodes.py
+++ b/src/puya/awst/nodes.py
@@ -310,8 +310,11 @@ def BigUIntConstant(  # noqa: N802
 
 @attrs.frozen
 class BoolConstant(Expression):
-    wtype: WType = attrs.field(default=wtypes.bool_wtype, init=False)
     value: bool
+    wtype: WType = attrs.field(
+        default=wtypes.bool_wtype,
+        validator=wtype_is_one_of(wtypes.bool_wtype, wtypes.arc4_bool_wtype),
+    )
 
     def accept(self, visitor: ExpressionVisitor[T]) -> T:
         return visitor.visit_bool_constant(self)
diff --git a/src/puya/ir/builder/main.py b/src/puya/ir/builder/main.py
index aeb0cdcb01..ef924716b8 100644
--- a/src/puya/ir/builder/main.py
+++ b/src/puya/ir/builder/main.py
@@ -373,9 +373,24 @@ def visit_decimal_constant(self, expr: awst_nodes.DecimalConstant) -> TExpressio
                 )
 
     def visit_bool_constant(self, expr: awst_nodes.BoolConstant) -> TExpression:
-        return UInt64Constant(
-            value=int(expr.value), ir_type=IRType.bool, source_location=expr.source_location
-        )
+        match expr.wtype:
+            case wtypes.bool_wtype:
+                return UInt64Constant(
+                    value=int(expr.value),
+                    ir_type=IRType.bool,
+                    source_location=expr.source_location,
+                )
+            case wtypes.arc4_bool_wtype:
+                return BytesConstant(
+                    value=(128 if expr.value else 0).to_bytes(1),
+                    encoding=AVMBytesEncoding.base16,
+                    ir_type=IRType.bytes,
+                    source_location=expr.source_location,
+                )
+            case _:
+                raise InternalError(
+                    f"Unexpected wtype {expr.wtype} for BoolConstant", expr.source_location
+                )
 
     def visit_bytes_constant(self, expr: awst_nodes.BytesConstant) -> BytesConstant:
         if len(expr.value) > algo_constants.MAX_BYTES_LENGTH:
diff --git a/src/puyapy/awst_build/eb/arc4/bool.py b/src/puyapy/awst_build/eb/arc4/bool.py
index 125ee92817..a9480e8b60 100644
--- a/src/puyapy/awst_build/eb/arc4/bool.py
+++ b/src/puyapy/awst_build/eb/arc4/bool.py
@@ -35,11 +35,9 @@ def try_convert_literal(
         match literal.value:
             case bool(bool_literal):
                 return ARC4BoolExpressionBuilder(
-                    ARC4Encode(
-                        value=BoolConstant(value=bool_literal, source_location=location),
-                        wtype=wtypes.arc4_bool_wtype,
-                        source_location=location,
-                    )
+                    BoolConstant(
+                        value=bool_literal, source_location=location, wtype=wtypes.arc4_bool_wtype
+                    ),
                 )
         return None
 
@@ -54,13 +52,16 @@ def call(
         arg = expect.at_most_one_arg(args, location)
         match arg:
             case None:
-                native_bool: Expression = BoolConstant(value=False, source_location=location)
+                expr: Expression = BoolConstant(
+                    value=False, source_location=location, wtype=wtypes.arc4_bool_wtype
+                )
             case _:
                 arg = expect.argument_of_type_else_dummy(arg, pytypes.BoolType)
                 native_bool = arg.resolve()
-        return ARC4BoolExpressionBuilder(
-            ARC4Encode(value=native_bool, wtype=wtypes.arc4_bool_wtype, source_location=location)
-        )
+                expr = ARC4Encode(
+                    value=native_bool, wtype=wtypes.arc4_bool_wtype, source_location=location
+                )
+        return ARC4BoolExpressionBuilder(expr)
 
 
 class ARC4BoolExpressionBuilder(
diff --git a/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.ir b/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.ir
index dd5f94163e..f3eb43524b 100644
--- a/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.ir
+++ b/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.ir
@@ -80,8 +80,7 @@ contract test_cases.arc4_types.bool_eval.Arc4BoolEvalContract:
                 let tmp%33#0: bool = (!= dynamic_arr#1 0x0000)
                 (assert tmp%33#0)
                 let encoded_bool%2#0: bytes = (setbit 0x00 0u 0u)
-                let encoded_bool%3#0: bytes = (setbit 0x00 0u 0u)
-                let tmp%34#0: bool = (== encoded_bool%2#0 encoded_bool%3#0)
+                let tmp%34#0: bool = (== 0x00 encoded_bool%2#0)
                 (assert tmp%34#0)
                 return 1u
     
diff --git a/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.opt_pass_1.ir b/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.opt_pass_1.ir
index 9aca817e1d..da24815852 100644
--- a/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.opt_pass_1.ir
+++ b/test_cases/arc4_types/out/Arc4BoolEvalContract.ssa.opt_pass_1.ir
@@ -76,8 +76,7 @@ contract test_cases.arc4_types.bool_eval.Arc4BoolEvalContract:
                 let tmp%33#0: bool = (!= dynamic_arr#1 0x0000)
                 (assert tmp%33#0)
                 let encoded_bool%2#0: bytes = 0x00
-                let encoded_bool%3#0: bytes = 0x00
-                let tmp%34#0: bool = (== encoded_bool%2#0 encoded_bool%3#0)
+                let tmp%34#0: bool = (== 0x00 encoded_bool%2#0)
                 (assert tmp%34#0)
                 return 1u
     
diff --git a/test_cases/arc4_types/out/module.awst b/test_cases/arc4_types/out/module.awst
index 6bb10b810a..f4f11ae97c 100644
--- a/test_cases/arc4_types/out/module.awst
+++ b/test_cases/arc4_types/out/module.awst
@@ -542,7 +542,7 @@ contract Arc4BoolEvalContract
     assert(dynamic_arr == hex<"0000">)
     dynamic_arr.extend((0_arc4u64))
     assert(dynamic_arr != hex<"0000">)
-    assert(arc4_encode(false, arc4.bool) == arc4_encode(false, arc4.bool))
+    assert(false == arc4_encode(false, arc4.bool))
     return true
   }
   
diff --git a/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.approval.teal b/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.approval.teal
index 96881d3c30..104218e626 100644
--- a/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.approval.teal
+++ b/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.approval.teal
@@ -215,9 +215,6 @@ test_cases.arc4_types.bool_eval.Arc4BoolEvalContract.approval_program:
     dup
     setbit
     bytec_0 // 0x00
-    intc_0 // 0
-    dup
-    setbit
     ==
     assert
     // arc4_types/bool_eval.py:58
diff --git a/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.destructured.ir b/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.destructured.ir
index af91ef7fe9..f291ef9ea7 100644
--- a/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.destructured.ir
+++ b/test_cases/arc4_types/out_unoptimized/Arc4BoolEvalContract.destructured.ir
@@ -80,8 +80,7 @@ contract test_cases.arc4_types.bool_eval.Arc4BoolEvalContract:
                 let tmp%33#0: bool = (!= dynamic_arr#0 0x0000)
                 (assert tmp%33#0)
                 let encoded_bool%2#0: bytes = (setbit 0x00 0u 0u)
-                let encoded_bool%3#0: bytes = (setbit 0x00 0u 0u)
-                let tmp%34#0: bool = (== encoded_bool%2#0 encoded_bool%3#0)
+                let tmp%34#0: bool = (== 0x00 encoded_bool%2#0)
                 (assert tmp%34#0)
                 return 1u
     
diff --git a/test_cases/arc4_types/puya.log b/test_cases/arc4_types/puya.log
index 2100a5fa5a..06a1155720 100644
--- a/test_cases/arc4_types/puya.log
+++ b/test_cases/arc4_types/puya.log
@@ -14736,7 +14736,6 @@ debug: Simplified (!= 0x00000000000000000000000000000000000000000000000000000000
 debug: Simplified (concat 0x0000 0x) to 0x0000
 debug: Simplified (concat 0x 0x0000000000000000) to 0x0000000000000000
 debug: Simplified (setbit 0x00 0u 0u) to 0x00
-debug: Simplified (setbit 0x00 0u 0u) to 0x00
 debug: Optimizer: Remove Unused Variables
 debug: Removing unused variable tmp%4#0
 debug: Removing unused variable tmp%5#0
@@ -14804,7 +14803,6 @@ debug: Removing unused variable tmp%31#0
 debug: Removing unused variable dynamic_arr#0
 debug: Removing unused variable data%0#0
 debug: Removing unused variable encoded_bool%2#0
-debug: Removing unused variable encoded_bool%3#0
 debug: Optimizer: Inner Txn Field Replacer
 debug: Optimizer: Replace Compiled References
 debug: Optimizer: Simplify Control Ops
diff --git a/test_cases/typed_abi_call/out/Greeter.ssa.ir b/test_cases/typed_abi_call/out/Greeter.ssa.ir
index 29adc7dff2..aaf96ae99c 100644
--- a/test_cases/typed_abi_call/out/Greeter.ssa.ir
+++ b/test_cases/typed_abi_call/out/Greeter.ssa.ir
@@ -1973,9 +1973,8 @@ contract test_cases.typed_abi_call.typed_c2c.Greeter:
                 let inner_txn_params%4%%Fee_length#0: uint64 = 1u
                 let inner_txn_params%4%%param_TypeEnum_idx_0#0: uint64 = appl
                 let inner_txn_params%4%%TypeEnum_length#0: uint64 = 1u
-                let encoded_bool%0#0: bytes = (setbit 0x00 0u 1u)
                 let inner_txn_params%4%%param_ApplicationArgs_idx_0#0: bytes = method "log(bool)void"
-                let inner_txn_params%4%%param_ApplicationArgs_idx_1#0: bytes = encoded_bool%0#0
+                let inner_txn_params%4%%param_ApplicationArgs_idx_1#0: bytes = 0x80
                 let inner_txn_params%4%%ApplicationArgs_length#0: uint64 = 2u
                 let inner_txn_params%4%%param_ApplicationID_idx_0#0: uint64 = app#0
                 let inner_txn_params%4%%ApplicationID_length#0: uint64 = 1u
diff --git a/test_cases/typed_abi_call/out/Greeter.ssa.opt_pass_1.ir b/test_cases/typed_abi_call/out/Greeter.ssa.opt_pass_1.ir
index 50ac2ab6ed..576a168f42 100644
--- a/test_cases/typed_abi_call/out/Greeter.ssa.opt_pass_1.ir
+++ b/test_cases/typed_abi_call/out/Greeter.ssa.opt_pass_1.ir
@@ -420,10 +420,9 @@ contract test_cases.typed_abi_call.typed_c2c.Greeter:
                 let tmp%7#0: bool = (== txn.LastLog#3 0x34)
                 (assert tmp%7#0)
                 itxn_begin
-                let encoded_bool%0#0: bytes = 0x80
                 ((itxn_field ApplicationID) app#0)
                 ((itxn_field ApplicationArgs) method "log(bool)void")
-                ((itxn_field ApplicationArgs) encoded_bool%0#0)
+                ((itxn_field ApplicationArgs) 0x80)
                 ((itxn_field TypeEnum) appl)
                 ((itxn_field Fee) 0u)
                 itxn_submit
diff --git a/test_cases/typed_abi_call/out/module.awst b/test_cases/typed_abi_call/out/module.awst
index a6cfbf202d..e04b39648c 100644
--- a/test_cases/typed_abi_call/out/module.awst
+++ b/test_cases/typed_abi_call/out/module.awst
@@ -166,7 +166,7 @@ contract Greeter
     assert(txn.LastLog == bzero(56u) + itob(3u))
     txn: inner_transaction_appl = submit_txn(create_inner_transaction(Fee=0u, TypeEnum=appl, ApplicationArgs=(Method("log(byte[])void"), arc4_encode(hex<"34">, arc4.dynamic_array<arc4.uint8>)), ApplicationID=app))
     assert(txn.LastLog == hex<"34">)
-    txn: inner_transaction_appl = submit_txn(create_inner_transaction(Fee=0u, TypeEnum=appl, ApplicationArgs=(Method("log(bool)void"), arc4_encode(true, arc4.bool)), ApplicationID=app))
+    txn: inner_transaction_appl = submit_txn(create_inner_transaction(Fee=0u, TypeEnum=appl, ApplicationArgs=(Method("log(bool)void"), true), ApplicationID=app))
     assert(txn.LastLog == hex<"54727565">)
   }
   
diff --git a/test_cases/typed_abi_call/out_unoptimized/Greeter.approval.teal b/test_cases/typed_abi_call/out_unoptimized/Greeter.approval.teal
index e2cfb0918c..1665ec5988 100644
--- a/test_cases/typed_abi_call/out_unoptimized/Greeter.approval.teal
+++ b/test_cases/typed_abi_call/out_unoptimized/Greeter.approval.teal
@@ -914,10 +914,6 @@ test_arg_conversion:
     // typed_abi_call/typed_c2c.py:69
     // txn = arc4.abi_call(Logger.log_bool, True, app_id=app)
     itxn_begin
-    pushbytes 0x00
-    intc_0 // 0
-    intc_3 // 1
-    setbit
     // typed_abi_call/typed_c2c.py:56
     // def test_arg_conversion(self, app: Application) -> None:
     frame_dig -1
@@ -926,6 +922,7 @@ test_arg_conversion:
     // txn = arc4.abi_call(Logger.log_bool, True, app_id=app)
     pushbytes 0x6eed7ec3 // method "log(bool)void"
     itxn_field ApplicationArgs
+    pushbytes 0x80
     itxn_field ApplicationArgs
     intc_1 // appl
     itxn_field TypeEnum
diff --git a/test_cases/typed_abi_call/out_unoptimized/Greeter.destructured.ir b/test_cases/typed_abi_call/out_unoptimized/Greeter.destructured.ir
index 0db1ae5d67..9badc3fe9f 100644
--- a/test_cases/typed_abi_call/out_unoptimized/Greeter.destructured.ir
+++ b/test_cases/typed_abi_call/out_unoptimized/Greeter.destructured.ir
@@ -499,12 +499,10 @@ contract test_cases.typed_abi_call.typed_c2c.Greeter:
                 let tmp%7#0: bool = (== txn.LastLog#0 0x34)
                 (assert tmp%7#0)
                 itxn_begin
-                let encoded_bool%0#0: bytes = (setbit 0x00 0u 1u)
-                let inner_txn_params%4%%param_ApplicationArgs_idx_1#0: bytes = encoded_bool%0#0
                 let inner_txn_params%4%%param_ApplicationID_idx_0#0: uint64 = app#0
                 ((itxn_field ApplicationID) inner_txn_params%4%%param_ApplicationID_idx_0#0)
                 ((itxn_field ApplicationArgs) method "log(bool)void")
-                ((itxn_field ApplicationArgs) inner_txn_params%4%%param_ApplicationArgs_idx_1#0)
+                ((itxn_field ApplicationArgs) 0x80)
                 ((itxn_field TypeEnum) appl)
                 ((itxn_field Fee) 0u)
                 goto block@5
diff --git a/test_cases/typed_abi_call/puya.log b/test_cases/typed_abi_call/puya.log
index dff7e91c06..58bd5b5435 100644
--- a/test_cases/typed_abi_call/puya.log
+++ b/test_cases/typed_abi_call/puya.log
@@ -3493,12 +3493,9 @@ debug: Found equivalence set: app#0, inner_txn_params%0%%param_ApplicationID_idx
 debug: Replacing {inner_txn_params%0%%param_ApplicationID_idx_0#0, inner_txn_params%1%%param_ApplicationID_idx_0#0, inner_txn_params%2%%param_ApplicationID_idx_0#0, inner_txn_params%3%%param_ApplicationID_idx_0#0, inner_txn_params%4%%param_ApplicationID_idx_0#0} with app#0 made 5 modifications
 debug: Found equivalence set: encoded_value%0#0, inner_txn_params%3%%param_ApplicationArgs_idx_1#0
 debug: Replacing {inner_txn_params%3%%param_ApplicationArgs_idx_1#0} with encoded_value%0#0 made 1 modifications
-debug: Found equivalence set: encoded_bool%0#0, inner_txn_params%4%%param_ApplicationArgs_idx_1#0
-debug: Replacing {inner_txn_params%4%%param_ApplicationArgs_idx_1#0} with encoded_bool%0#0 made 1 modifications
 debug: Optimizer: Intrinsic Simplifier
 debug: Simplified (concat tmp%3#0 tmp%4#0) to 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
 debug: Simplified (len 0x34) to 1u
-debug: Simplified (setbit 0x00 0u 1u) to 0x80
 debug: Optimizer: Remove Unused Variables
 debug: Removing unused variable inner_txn_params%0#0
 debug: Removing unused variable inner_txn_params%0%%param_Fee_idx_0#0
@@ -3979,6 +3976,7 @@ debug: Removing unused variable inner_txn_params%4%%Fee_length#0
 debug: Removing unused variable inner_txn_params%4%%param_TypeEnum_idx_0#0
 debug: Removing unused variable inner_txn_params%4%%TypeEnum_length#0
 debug: Removing unused variable inner_txn_params%4%%param_ApplicationArgs_idx_0#0
+debug: Removing unused variable inner_txn_params%4%%param_ApplicationArgs_idx_1#0
 debug: Removing unused variable inner_txn_params%4%%ApplicationArgs_length#0
 debug: Removing unused variable inner_txn_params%4%%ApplicationID_length#0
 debug: Removing unused variable inner_txn_params%4%%Sender_length#0
@@ -8889,7 +8887,6 @@ debug: Optimizer: Remove Unused Variables
 debug: Removing unused variable tmp%5#0
 debug: Removing unused variable length%0#0
 debug: Removing unused variable as_bytes%0#0
-debug: Removing unused variable encoded_bool%0#0
 debug: Optimizer: Inner Txn Field Replacer
 debug: Optimizer: Replace Compiled References
 debug: Optimizer: Simplify Control Ops