; Pin: canMergeStoresTo refuses to merge i16 stores into i32+.
;
; The SDAG store-merge combine sees two adjacent i16 stores and tries
; to widen them into one i32 store.  Our i32 store path is Custom-
; lowered back to two i16 stores, and the merge runs again, and the
; cycle repeats until OOM.  Override fixes it by capping merge MemVT
; at i16.  See feedback_canmergestores_disable.md.
;
; Repro: write two adjacent i16 fields of a struct.  Without the cap,
; this either OOMs or burns >5s on a 4-line function.  With the cap,
; the lowered code shows two distinct i16 stores (no widened form).
;
; RUN: llc -mtriple=w65816 -O2 < %s | FileCheck %s

%struct.Pair = type { i16, i16 }

define void @write_pair(ptr %p, i16 %a, i16 %b) {
; CHECK-LABEL: write_pair:
; Two distinct i16 stores must remain — not merged into one i32.
; Each i16 store under our i32-illegal path uses the same DP-indirect
; family ([dp],y) but on a freshly-loaded $e0 pointer for each half.
; CHECK:       sta [0xe0
; CHECK:       sta [0xe0
; CHECK:       rtl
  %f0 = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 0
  %f1 = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1
  store i16 %a, ptr %f0
  store i16 %b, ptr %f1
  ret void
}
