[llvm] [AMDGPU] Accept extractelement of a widening cast when folding image ops to a16 (PR #208207)
Sebastian Neubauer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 03:56:10 PDT 2026
================
@@ -115,6 +125,14 @@ static Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
Type *VTy = V.getType();
if (isa<FPExtInst, SExtInst, ZExtInst>(&V))
return cast<Instruction>(&V)->getOperand(0);
+ // Vector form: extractelement((s|z|fp)ext Vec), Idx -> extractelement(Vec,
+ // Idx), taking the narrow lane directly so the widening cast can be removed.
+ Value *VecCast, *Idx;
+ if (match(&V, m_ExtractElt(PatternMatch::m_Value(VecCast),
+ PatternMatch::m_Value(Idx))) &&
+ isa<FPExtInst, SExtInst, ZExtInst>(VecCast))
+ return Builder.CreateExtractElement(
+ cast<Instruction>(VecCast)->getOperand(0), Idx);
----------------
Flakebi wrote:
Should be able to use `m_Instruction` instead of `m_Value` above and eliminate the cast here
https://github.com/llvm/llvm-project/pull/208207
More information about the llvm-commits
mailing list