diff --git a/numba/cpython/tupleobj.py b/numba/cpython/tupleobj.py
index 7a547577f..34739623f 100644
--- a/numba/cpython/tupleobj.py
+++ b/numba/cpython/tupleobj.py
@@ -187,6 +187,24 @@ def iternext_unituple(context, builder, sig, args, result):
         builder.store(nidx, iterval.index)
 
 
+@overload(operator.getitem)
+def getitem_literal_idx(tup, idx):
+    """
+    Overloads BaseTuple getitem to cover cases where constant
+    inference and RewriteConstGetitems cannot replace it
+    with a static_getitem.
+    """
+    if not (isinstance(tup, types.BaseTuple)
+            and isinstance(idx, types.IntegerLiteral)):
+        return None
+
+    idx_val = idx.literal_value
+    def getitem_literal_idx_impl(tup, idx):
+        return tup[idx_val]
+
+    return getitem_literal_idx_impl
+
+
 @lower_builtin('typed_getitem', types.BaseTuple, types.Any)
 def getitem_typed(context, builder, sig, args):
     tupty, _ = sig.args

Tuple getitem cannot compile with IntegerLiterals as index
- [x] I have tried 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).

Hi,

We recently found some code in our code base, that was obviously used to extend operator.getitem for BaseTuple types and IntegerLiterals as index. Without it the following fails to compile:
```
import operator
import numpy as np

import numba
from numba import types
from numba.core import cgutils
from numba import literally
from numba.extending import (
    make_attribute_wrapper,
    overload,
    models,
    register_model,
    type_callable,
    typeof_impl,
    lower_builtin,
)

def make_dummy_type():
    class Dummy(object):
        def __init__(self, value):
            self.value = value

    class DummyType(types.Type):
        def __init__(self, data):
            self.data = data
            super(DummyType, self).__init__(name="Dummy({})".format(data))

    @register_model(DummyType)
    class DummyModel(models.StructModel):
        def __init__(self, dmm, fe_type):
            data_type = types.Tuple(fe_type.data)
            members = [("data", data_type)]
            models.StructModel.__init__(self, dmm, fe_type, members)

    make_attribute_wrapper(DummyType, "data", "_data")

    @type_callable(Dummy)
    def type_dummy(context):
        def typer(value):
            return DummyType(value)

        return typer

    @lower_builtin(Dummy, types.Tuple)
    def impl_dummy(context, builder, sig, args):
        typ = sig.return_type
        [value] = args
        dummy = cgutils.create_struct_proxy(typ)(context, builder)
        dummy.data = value
        return dummy._getvalue()


    @typeof_impl.register(Dummy)
    def typeof_dummy(val, c):
        return DummyType(val)

    # Store attributes
    return Dummy, DummyType

Dummy, DummyType = make_dummy_type()

@overload(operator.getitem)
def dummy_getitem_ovld(self, idx):
    if not isinstance(self, DummyType):
        return None

    if isinstance(idx, types.IntegerLiteral):
        def dummy_getitem_impl(self, idx):
            return self._data[idx]

        return dummy_getitem_impl

@numba.njit
def test_impl_issue(x):
    d = Dummy(x)
    return d[0]


n = 11
a1 = np.ones(n, dtype='int')
a2 = np.arange(n, dtype=np.float64)
a3 = np.random.ranf(n)
print("DEBUG:", test_impl_issue((a1, a2, a3)))
```

And the error is following:
```
No implementation of function Function(<built-in function getitem>) found for signature:

 >>> getitem(Tuple(array(int32, 1d, C), array(float64, 1d, C), array(float64, 1d, C)), Literal[int](0))

There are 18 candidate implementations:
   - Of which 18 did not match due to:
   Overload of function 'getitem': File: <numerous>: Line N/A.
     With argument(s): '(Tuple(array(int32, 1d, C), array(float64, 1d, C), array(float64, 1d, C)), Literal[int](0))':
    No match.
```

As far as I see from the func_ir 'getitem' expr is not transformed to 'static_getitem', since idx is not const and so this continues to type_inference_stage and fails, since probably there are no templates that can handle this:
```
------------IR DUMP: dummy_getitem_ovld.<locals>.dummy_getitem_impl-------------
label 0:
    self = arg(0, name=self)                 ['self']
    idx = arg(1, name=idx)                   ['idx']
    $4load_attr.1 = getattr(value=self, attr=_data) ['$4load_attr.1', 'self']
    $8binary_subscr.3 = getitem(value=$4load_attr.1, index=idx) ['$4load_attr.1', '$8binary_subscr.3', 'idx']
    $10return_value.4 = cast(value=$8binary_subscr.3) ['$10return_value.4', '$8binary_subscr.3']
    return $10return_value.4                 ['$10return_value.4']
```

After that I found below simple script also fails:
```
import operator
import numpy as np
import numba
from numba import types
from numba.extending import overload

def bar(tup, idx):
    pass

@overload(bar)
def bar_ovld(tup, idx):
    if not isinstance(idx, types.IntegerLiteral):
        return None

    def _impl(tup, idx):
        return tup[idx]        # it works with attr[0]
    return _impl

@numba.njit
def test_bar(arrs):
    return bar(arrs, 0)

n = 11
a1 = np.ones(n, dtype=np.int32)
a2 = np.arange(n, dtype=np.float64)
a3 = np.random.ranf(n)
tup_of_arrays = (a1, a2, a3,)
print("DEBUG:", test_bar(tup_of_arrays))
```



Do you think we can add below code to Numba to fix this?
```
@overload(operator.getitem)
def base_tuple_getitem_ovld(tup, idx):
    if not (isinstance(tup, types.BaseTuple)
            and isinstance(idx, types.IntegerLiteral)):
        return None
    idx_val = idx.literal_value
    def base_tuple_getitem_impl(tup, idx):
        return tup[idx_val]
    return base_tuple_getitem_impl
```

I was using Numba: 0.51.0.dev0+147.g7bb3157cf

Best Regards,
Alexey.
diff --git a/numba/tests/test_tuples.py b/numba/tests/test_tuples.py
index dfd93ad0e..f0ae01167 100644
--- a/numba/tests/test_tuples.py
+++ b/numba/tests/test_tuples.py
@@ -4,7 +4,7 @@ import itertools
 import numpy as np
 
 from numba.core.compiler import compile_isolated
-from numba import njit, jit, typeof
+from numba import njit, jit, typeof, literally
 from numba.core import types, errors, utils
 from numba.tests.support import TestCase, MemoryLeakMixin, tag
 import unittest
@@ -218,6 +218,17 @@ class TestOperations(TestCase):
                               [types.UniTuple(types.int64, 3)])
         self.assertPreciseEqual(cr.entry_point((4, 5, 6)), 3)
 
+    def test_index_literal(self):
+        # issue #6023, test non-static getitem with IntegerLiteral index
+        def pyfunc(tup, idx):
+            idx = literally(idx)
+            return tup[idx]
+        cfunc = njit(pyfunc)
+
+        tup = (4, 3.1, 'sss')
+        for i in range(len(tup)):
+            self.assertPreciseEqual(cfunc(tup, i), tup[i])
+
     def test_index(self):
         pyfunc = tuple_index
         cr = compile_isolated(pyfunc,

pip install -e .
parse_log_pytest
requirements.txt
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
exceptiongroup==1.2.2
importlib-metadata==6.7.0
iniconfig==2.0.0
llvmlite==0.33.0
-e git+https://github.com/numba/numba.git@d3b7ea1344779cf0bacfa82c754da5b71e133dbe#egg=numba
numpy==1.21.6
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
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
      - exceptiongroup==1.2.2
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - llvmlite==0.33.0
      - numpy==1.21.6
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/numba

numba/tests/test_tuples.py::TestOperations::test_index_literal
numba/tests/test_tuples.py::TestTupleLengthError::test_tuple_length_error numba/tests/test_tuples.py::TestTupleTypeNotIterable::test_namedtuple_types_exception numba/tests/test_tuples.py::TestTupleTypeNotIterable::test_tuple_types_exception numba/tests/test_tuples.py::TestTupleReturn::test_array_tuple numba/tests/test_tuples.py::TestTupleReturn::test_hetero_tuple numba/tests/test_tuples.py::TestTupleReturn::test_scalar_tuple numba/tests/test_tuples.py::TestTuplePassing::test_hetero_tuple numba/tests/test_tuples.py::TestTuplePassing::test_size_mismatch numba/tests/test_tuples.py::TestTuplePassing::test_unituple numba/tests/test_tuples.py::TestOperations::test_add numba/tests/test_tuples.py::TestOperations::test_bool numba/tests/test_tuples.py::TestOperations::test_eq numba/tests/test_tuples.py::TestOperations::test_ge numba/tests/test_tuples.py::TestOperations::test_gt numba/tests/test_tuples.py::TestOperations::test_in numba/tests/test_tuples.py::TestOperations::test_index numba/tests/test_tuples.py::TestOperations::test_le numba/tests/test_tuples.py::TestOperations::test_len numba/tests/test_tuples.py::TestOperations::test_lt numba/tests/test_tuples.py::TestOperations::test_ne numba/tests/test_tuples.py::TestOperations::test_slice2 numba/tests/test_tuples.py::TestOperations::test_slice3 numba/tests/test_tuples.py::TestNamedTuple::test_bool numba/tests/test_tuples.py::TestNamedTuple::test_construct numba/tests/test_tuples.py::TestNamedTuple::test_dispatcher_mistreat numba/tests/test_tuples.py::TestNamedTuple::test_eq numba/tests/test_tuples.py::TestNamedTuple::test_ge numba/tests/test_tuples.py::TestNamedTuple::test_getattr numba/tests/test_tuples.py::TestNamedTuple::test_gt numba/tests/test_tuples.py::TestNamedTuple::test_index numba/tests/test_tuples.py::TestNamedTuple::test_le numba/tests/test_tuples.py::TestNamedTuple::test_len numba/tests/test_tuples.py::TestNamedTuple::test_literal_unification numba/tests/test_tuples.py::TestNamedTuple::test_lt numba/tests/test_tuples.py::TestNamedTuple::test_ne numba/tests/test_tuples.py::TestNamedTuple::test_string_literal_in_ctor numba/tests/test_tuples.py::TestNamedTuple::test_type numba/tests/test_tuples.py::TestNamedTuple::test_unpack numba/tests/test_tuples.py::TestTupleNRT::test_tuple_add numba/tests/test_tuples.py::TestNamedTupleNRT::test_return numba/tests/test_tuples.py::TestConversions::test_conversions numba/tests/test_tuples.py::TestMethods::test_index numba/tests/test_tuples.py::TestTupleBuild::test_build_unpack numba/tests/test_tuples.py::TestTupleBuild::test_build_unpack_call numba/tests/test_tuples.py::TestTupleBuild::test_build_unpack_call_more numba/tests/test_tuples.py::TestTupleBuild::test_build_unpack_more numba/tests/test_tuples.py::TestTupleBuild::test_tuple_constructor
numba/cpython/tupleobj.py
numba/cpython/tupleobj.py