[AMDGPU] Only fold 32-bit shift sources in isExtractHiElt (#215245)
D16 image sample returns 4-time 16-bit samples packed into 64 bits. The
backend legalizes extractelement <4 x half>, 1 (channel 1 — the upper
half of the first dword) into trunc(srl(i64, 16)). At normal
optimization levels the DAG combiner splits the i64 into two i32s before
instruction selection, hiding the problem. At -O0 the i64 survives
intact. This creates an invalid COPY from a 64-bit virtual register to a
32-bit physical register, which asserts in SIInstrInfo::copyPhysReg.
To fix it, in isExtractHiElt (both the SelectionDAG version in
AMDGPUISelDAGToDAG.cpp and the GlobalISel version in
AMDGPUInstructionSelector.cpp), check that the shift source is exactly
32 bits before folding.