; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2026 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================

; REQUIRES: regkeys
; RUN: igc_opt -resolve-image-implicit-args-for-bindless --opaque-pointers -regkey ForceEnableSurfaceStateSizeReloc=1  -S %s | FileCheck %s

target triple = "spir64-unknown-unknown"

%spirv.Sampler = type opaque


define spir_func void @test_width(i64 %bindless_img) {
; CHECK-LABEL: @test_width(
; CHECK-NEXT:    [[SURFACESTATESIZE:%.*]] = call i32 @llvm.genx.GenISA.staticConstantPatchValue.i32.a26i8([26 x i8] c"__INTEL_SURFACE_STATE_SIZE")
; CHECK-NEXT:    [[TMP1:%.*]] = zext i32 [[SURFACESTATESIZE]] to i64
; CHECK-NEXT:    [[TMP2:%.*]] = add i64 [[BINDLESS_IMG:%.*]], [[TMP1]]
; CHECK-NEXT:    [[IMAGEIMPLICITARGS:%.*]] = inttoptr i64 [[TMP2]] to ptr addrspace(393468)
; CHECK-NEXT:    [[TMP3:%.*]] = call i32 @llvm.genx.GenISA.ldraw.indexed.i32.p393468(ptr addrspace(393468) [[IMAGEIMPLICITARGS]], i32 8, i32 8, i1 false)
; CHECK-NEXT:    ret void
;
  %1 = call i32 @__builtin_IB_get_image_width(i64 %bindless_img)
  ret void
}

declare spir_func i32 @__builtin_IB_get_image_width(i64 noundef) local_unnamed_addr

!IGCMetadata = !{!0}

!0 = !{!"ModuleMD", !1, !2}
!1 = !{!"UseBindlessImage", i1 true}
!2 = !{!"extensions", !3}
!3 = !{!"spvINTELBindlessImages", i1 true}
