diff --git a/numba/core/analysis.py b/numba/core/analysis.py
index 54342b488..9c5423738 100644
--- a/numba/core/analysis.py
+++ b/numba/core/analysis.py
@@ -283,6 +283,10 @@ def _fix_loop_exit(cfg, loop):
         return loop
 
 
+# Used to describe a nullified condition in dead branch pruning
+nullified = namedtuple('nullified', 'condition, taken_br, rewrite_stmt')
+
+
 # Functions to manipulate IR
 def dead_branch_prune(func_ir, called_args):
     """
@@ -429,7 +433,8 @@ def dead_branch_prune(func_ir, called_args):
                 prune_stat, taken = prune(branch, condition, blk, *const_conds)
                 if(prune_stat):
                     # add the condition to the list of nullified conditions
-                    nullified_conditions.append((condition, taken))
+                    nullified_conditions.append(nullified(condition, taken,
+                                                          True))
         else:
             # see if this is a branch on a constant value predicate
             resolved_const = Unknown()
@@ -444,7 +449,8 @@ def dead_branch_prune(func_ir, called_args):
                 prune_stat, taken = prune_by_predicate(branch, condition, blk)
                 if(prune_stat):
                     # add the condition to the list of nullified conditions
-                    nullified_conditions.append((condition, taken))
+                    nullified_conditions.append(nullified(condition, taken,
+                                                          False))
 
     # 'ERE BE DRAGONS...
     # It is the evaluation of the condition expression that often trips up type
@@ -461,18 +467,22 @@ def dead_branch_prune(func_ir, called_args):
     # completeness the func_ir._definitions and ._consts are also updated to
     # make the IR state self consistent.
 
-    deadcond = [x[0] for x in nullified_conditions]
+    deadcond = [x.condition for x in nullified_conditions]
     for _, cond, blk in branch_info:
         if cond in deadcond:
             for x in blk.body:
                 if isinstance(x, ir.Assign) and x.value is cond:
                     # rewrite the condition as a true/false bit
-                    branch_bit = nullified_conditions[deadcond.index(cond)][1]
-                    x.value = ir.Const(branch_bit, loc=x.loc)
-                    # update the specific definition to the new const
-                    defns = func_ir._definitions[x.target.name]
-                    repl_idx = defns.index(cond)
-                    defns[repl_idx] = x.value
+                    nullified_info = nullified_conditions[deadcond.index(cond)]
+                    # only do a rewrite of conditions, predicates need to retain
+                    # their value as they may be used later.
+                    if nullified_info.rewrite_stmt:
+                        branch_bit = nullified_info.taken_br
+                        x.value = ir.Const(branch_bit, loc=x.loc)
+                        # update the specific definition to the new const
+                        defns = func_ir._definitions[x.target.name]
+                        repl_idx = defns.index(cond)
+                        defns[repl_idx] = x.value
 
     # Remove dead blocks, this is safe as it relies on the CFG only.
     cfg = compute_cfg_from_blocks(func_ir.blocks)
diff --git a/numba/typed/typedlist.py b/numba/typed/typedlist.py
index 82259b5bc..2d3efd195 100644
--- a/numba/typed/typedlist.py
+++ b/numba/typed/typedlist.py
@@ -355,14 +355,13 @@ class List(MutableSequence):
         return _pop(self, i)
 
     def extend(self, iterable):
-        # Empty iterable, do nothing
-        if len(iterable) == 0:
-            return self
         if not self._typed:
             # Need to get the first element of the iterable to initialise the
             # type of the list. FIXME: this may be a problem if the iterable
             # can not be sliced.
             self._initialise_list(iterable[0])
+            self.append(iterable[0])
+            return _extend(self, iterable[1:])
         return _extend(self, iterable)
 
     def remove(self, item):

Jit produces wrong code with version 0.49.0
[Our library's](https://github.com/pymatting/pymatting/issues/15) tests [fail on all platforms](https://travis-ci.org/github/pymatting/pymatting/builds/678580669) when upgrading from numba version `0.48.0` to `0.49.0`.

The smallest test case that I could come up with that still reproduces the issue is the following:

```Python
import numpy as np
from numba import jit

def foo():
    values = np.zeros(1)
    tmp = 666
    if tmp:
        values[0] = tmp
        print(values)

print("Without jit")
foo()
print("With jit")
jit(foo)()
```

It prints `666.0` with Python and `1.0` when jitted.

- [ x ] I am using the latest released version of Numba (most recent is visible in
 the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- [ x ] I have included below a minimal working reproducer (if you are unsure how
 to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).

diff --git a/numba/tests/test_analysis.py b/numba/tests/test_analysis.py
index 89336d3b8..72ae9a935 100644
--- a/numba/tests/test_analysis.py
+++ b/numba/tests/test_analysis.py
@@ -697,7 +697,7 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if const:
-                        return 3.14159
+                        return 3.14159, const
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
 
@@ -707,7 +707,7 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if not const:
-                        return 3.14159
+                        return 3.14159, const
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
 
@@ -717,9 +717,9 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if const:
-                        return 3.14159
+                        return 3.14159, const
                     else:
-                        return 1.61803
+                        return 1.61803, const
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
 
@@ -729,9 +729,9 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if not const:
-                        return 3.14159
+                        return 3.14159, const
                     else:
-                        return 1.61803
+                        return 1.61803, const
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
 
@@ -746,7 +746,7 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if c_test_single_if_global:
-                        return 3.14159
+                        return 3.14159, c_test_single_if_global
 
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
@@ -760,7 +760,7 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if c_test_single_if_negate_global:
-                        return 3.14159
+                        return 3.14159, c_test_single_if_negate_global
 
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
@@ -774,9 +774,9 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if c_test_single_if_else_global:
-                        return 3.14159
+                        return 3.14159, c_test_single_if_else_global
                     else:
-                        return 1.61803
+                        return 1.61803, c_test_single_if_else_global
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
 
@@ -789,12 +789,25 @@ class TestBranchPrunePredicates(TestBranchPruneBase, SerialMixin):
 
                 def func(x):
                     if not c_test_single_if_else_negate_global:
-                        return 3.14159
+                        return 3.14159, c_test_single_if_else_negate_global
                     else:
-                        return 1.61803
+                        return 1.61803, c_test_single_if_else_negate_global
                 self.assert_prune(func, (types.NoneType('none'),), [prune],
                                   None)
 
+    def test_issue_5618(self):
+
+        @njit
+        def foo():
+            values = np.zeros(1)
+            tmp = 666
+            if tmp:
+                values[0] = tmp
+            return values
+
+        self.assertPreciseEqual(foo.py_func()[0], 666.)
+        self.assertPreciseEqual(foo()[0], 666.)
+
 
 class TestBranchPrunePostSemanticConstRewrites(TestBranchPruneBase):
     # Tests that semantic constants rewriting works by virtue of branch pruning
diff --git a/numba/tests/test_typedlist.py b/numba/tests/test_typedlist.py
index 3ce886f07..72f17fb5a 100644
--- a/numba/tests/test_typedlist.py
+++ b/numba/tests/test_typedlist.py
@@ -738,33 +738,6 @@ class TestExtend(MemoryLeakMixin, TestCase):
         got = impl()
         self.assertEqual(expected, got)
 
-    def test_extend_single_value_container(self):
-        @njit
-        def impl():
-            l = List()
-            l.extend((100,))
-            return l
-
-        expected = impl.py_func()
-        got = impl()
-        self.assertEqual(expected, got)
-
-    def test_extend_empty_unrefined(self):
-        # Extending an unrefined list with an empty iterable doesn't work in a
-        # jit compiled function as the list remains untyped.
-        l = List()
-        l.extend(tuple())
-        self.assertEqual(len(l), 0)
-        self.assertFalse(l._typed)
-
-    def test_extend_empty_refiend(self):
-        # Extending a refined list with an empty iterable doesn't work in a
-        # jit compiled function as the (empty) argument can't be typed
-        l = List((1,))
-        l.extend(tuple())
-        self.assertEqual(len(l), 1)
-        self.assertTrue(l._typed)
-
 
 @njit
 def cmp(a, b):

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio pytest
apt-get update apt-get install -y gcc g++
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==7.2.7
exceptiongroup==1.2.2
execnet==2.0.2
importlib-metadata==6.7.0
iniconfig==2.0.0
llvmlite==0.32.1
-e git+https://github.com/numba/numba.git@1dabbf67426ad6243f7b6d791d3d38dbb68ab33e#egg=numba
numpy==1.21.6
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: numba
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argparse==1.4.0
      - coverage==7.2.7
      - exceptiongroup==1.2.2
      - execnet==2.0.2
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - llvmlite==0.32.1
      - numpy==1.21.6
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - pytest-asyncio==0.21.2
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/numba

numba/tests/test_analysis.py::TestBranchPrunePredicates::test_issue_5618
numba/tests/test_analysis.py::TestBranchPrune::test_comparison_operators numba/tests/test_analysis.py::TestBranchPrune::test_cond_is_kwarg_none numba/tests/test_analysis.py::TestBranchPrune::test_cond_is_kwarg_value numba/tests/test_analysis.py::TestBranchPrune::test_cond_rewrite_is_correct numba/tests/test_analysis.py::TestBranchPrune::test_double_if_else_non_literal_const numba/tests/test_analysis.py::TestBranchPrune::test_double_if_else_rt_const numba/tests/test_analysis.py::TestBranchPrune::test_freevar_bake_in numba/tests/test_analysis.py::TestBranchPrune::test_global_bake_in numba/tests/test_analysis.py::TestBranchPrune::test_obj_mode_fallback numba/tests/test_analysis.py::TestBranchPrune::test_redefined_variables_are_not_considered_in_prune numba/tests/test_analysis.py::TestBranchPrune::test_redefinition_analysis_different_block_can_exec numba/tests/test_analysis.py::TestBranchPrune::test_redefinition_analysis_different_block_cannot_exec numba/tests/test_analysis.py::TestBranchPrune::test_redefinition_analysis_same_block numba/tests/test_analysis.py::TestBranchPrune::test_single_if numba/tests/test_analysis.py::TestBranchPrune::test_single_if_const_val numba/tests/test_analysis.py::TestBranchPrune::test_single_if_else numba/tests/test_analysis.py::TestBranchPrune::test_single_if_else_two_const_val numba/tests/test_analysis.py::TestBranchPrune::test_single_if_else_w_following_undetermined numba/tests/test_analysis.py::TestBranchPrune::test_single_two_branches_same_cond numba/tests/test_analysis.py::TestBranchPrunePredicates::test_literal_const_code_gen numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_const numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_else_const numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_else_freevar numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_else_global numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_else_negate_const numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_else_negate_freevar numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_else_negate_global numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_freevar numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_global numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_negate_const numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_negate_freevar numba/tests/test_analysis.py::TestBranchPrunePredicates::test_single_if_negate_global numba/tests/test_analysis.py::TestBranchPrunePostSemanticConstRewrites::test_array_ndim_attr numba/tests/test_analysis.py::TestBranchPrunePostSemanticConstRewrites::test_attr_not_len numba/tests/test_analysis.py::TestBranchPrunePostSemanticConstRewrites::test_ndim_not_on_array numba/tests/test_analysis.py::TestBranchPrunePostSemanticConstRewrites::test_semantic_const_propagates_before_static_rewrites numba/tests/test_analysis.py::TestBranchPrunePostSemanticConstRewrites::test_tuple_len numba/tests/test_typedlist.py::TestTypedList::test_basic numba/tests/test_typedlist.py::TestTypedList::test_catch_global_typed_list numba/tests/test_typedlist.py::TestTypedList::test_compiled numba/tests/test_typedlist.py::TestTypedList::test_delitem_slice numba/tests/test_typedlist.py::TestTypedList::test_dtype numba/tests/test_typedlist.py::TestTypedList::test_dtype_raises_exception_on_untyped_list numba/tests/test_typedlist.py::TestTypedList::test_getitem_slice numba/tests/test_typedlist.py::TestTypedList::test_list_create_no_jit_using_List numba/tests/test_typedlist.py::TestTypedList::test_list_create_no_jit_using_empty_list numba/tests/test_typedlist.py::TestTypedList::test_list_extend_refines_on_unicode_type numba/tests/test_typedlist.py::TestTypedList::test_repr numba/tests/test_typedlist.py::TestTypedList::test_setitem_slice numba/tests/test_typedlist.py::TestTypedList::test_setitem_slice_value_error numba/tests/test_typedlist.py::TestTypedList::test_unsigned_access numba/tests/test_typedlist.py::TestTypedList::test_unsigned_prange numba/tests/test_typedlist.py::TestNoneType::test_append_none numba/tests/test_typedlist.py::TestNoneType::test_equals_none numba/tests/test_typedlist.py::TestNoneType::test_getitem_none numba/tests/test_typedlist.py::TestNoneType::test_iter_none numba/tests/test_typedlist.py::TestNoneType::test_len_none numba/tests/test_typedlist.py::TestNoneType::test_none_typed_method_fails numba/tests/test_typedlist.py::TestNoneType::test_not_equals_none numba/tests/test_typedlist.py::TestNoneType::test_setitem_none numba/tests/test_typedlist.py::TestAllocation::test_allocation numba/tests/test_typedlist.py::TestAllocation::test_allocation_njit numba/tests/test_typedlist.py::TestAllocation::test_growth_and_shrinkage numba/tests/test_typedlist.py::TestExtend::test_extend_other numba/tests/test_typedlist.py::TestExtend::test_extend_self numba/tests/test_typedlist.py::TestExtend::test_extend_tuple numba/tests/test_typedlist.py::TestComparisons::test_empty_vs_empty numba/tests/test_typedlist.py::TestComparisons::test_empty_vs_singleton numba/tests/test_typedlist.py::TestComparisons::test_equal numba/tests/test_typedlist.py::TestComparisons::test_equals_non_list numba/tests/test_typedlist.py::TestComparisons::test_first_greater_than numba/tests/test_typedlist.py::TestComparisons::test_first_less_than numba/tests/test_typedlist.py::TestComparisons::test_first_shorter numba/tests/test_typedlist.py::TestComparisons::test_second_shorter numba/tests/test_typedlist.py::TestComparisons::test_singleton_vs_empty numba/tests/test_typedlist.py::TestComparisons::test_singleton_vs_singleton_equal numba/tests/test_typedlist.py::TestComparisons::test_singleton_vs_singleton_greater_than numba/tests/test_typedlist.py::TestComparisons::test_singleton_vs_singleton_less_than numba/tests/test_typedlist.py::TestListInferred::test_refine_extend_list numba/tests/test_typedlist.py::TestListInferred::test_refine_extend_set numba/tests/test_typedlist.py::TestListInferred::test_refine_list_extend_iter numba/tests/test_typedlist.py::TestListInferred::test_simple_refine_append numba/tests/test_typedlist.py::TestListInferred::test_simple_refine_insert numba/tests/test_typedlist.py::TestListRefctTypes::test_array_as_item_in_list numba/tests/test_typedlist.py::TestListRefctTypes::test_dict_as_item_in_list numba/tests/test_typedlist.py::TestListRefctTypes::test_dict_as_item_in_list_multi_refcount numba/tests/test_typedlist.py::TestListRefctTypes::test_equals_on_list_with_dict_for_equal_lists numba/tests/test_typedlist.py::TestListRefctTypes::test_equals_on_list_with_dict_for_unequal_dicts numba/tests/test_typedlist.py::TestListRefctTypes::test_equals_on_list_with_dict_for_unequal_lists numba/tests/test_typedlist.py::TestListRefctTypes::test_jitclass_as_item_in_list numba/tests/test_typedlist.py::TestListRefctTypes::test_list_as_item_in_list numba/tests/test_typedlist.py::TestListRefctTypes::test_list_as_value_in_dict numba/tests/test_typedlist.py::TestListRefctTypes::test_storage_model_mismatch numba/tests/test_typedlist.py::TestListRefctTypes::test_str_item numba/tests/test_typedlist.py::TestListRefctTypes::test_str_item_refcount_replace numba/tests/test_typedlist.py::TestListSort::test_sort_all_args numba/tests/test_typedlist.py::TestListSort::test_sort_dispatcher_key numba/tests/test_typedlist.py::TestListSort::test_sort_in_jit_w_global_key numba/tests/test_typedlist.py::TestListSort::test_sort_in_jit_w_lambda_key numba/tests/test_typedlist.py::TestListSort::test_sort_no_args numba/tests/test_typedlist.py::TestListSort::test_sort_on_arrays numba/tests/test_typedlist.py::TestImmutable::test_append_fails numba/tests/test_typedlist.py::TestImmutable::test_getitem_still_works_when_immutable numba/tests/test_typedlist.py::TestImmutable::test_is_immutable numba/tests/test_typedlist.py::TestImmutable::test_length_still_works_when_immutable numba/tests/test_typedlist.py::TestImmutable::test_make_immutable_is_immutable numba/tests/test_typedlist.py::TestImmutable::test_mutation_fails numba/tests/test_typedlist.py::TestListFromIter::test_dict_iters numba/tests/test_typedlist.py::TestListFromIter::test_exception_on_inhomogeneous_tuple numba/tests/test_typedlist.py::TestListFromIter::test_exception_on_kwargs numba/tests/test_typedlist.py::TestListFromIter::test_exception_on_plain_int numba/tests/test_typedlist.py::TestListFromIter::test_exception_on_too_many_args numba/tests/test_typedlist.py::TestListFromIter::test_ndarray_oned numba/tests/test_typedlist.py::TestListFromIter::test_ndarray_scalar numba/tests/test_typedlist.py::TestListFromIter::test_ndarray_twod numba/tests/test_typedlist.py::TestListFromIter::test_simple_iterable_types numba/tests/test_typedlist.py::TestListFromIter::test_unicode
numba/typed/typedlist.py numba/core/analysis.py
numba/typed/typedlist.py numba/core/analysis.py