[PATCH] D132938: [AMDGPU] Fix crash legalizing G_EXTRACT_VECTOR_ELT with negative index

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 30 07:32:10 PDT 2022


Petar.Avramovic added a comment.

IdxVal >= 0 check looks fine to me,
but what looks wrong in this test is that i1 1(true in llvm ir) index is translated to `%7:_(s32) = G_CONSTANT i32 -1`
`IRTranslator::translateExtractElement` did not expect i1 indices and since indices are (afaik) positive zext would make more sense then sext in:
`APInt NewIdx = CI->getValue().sextOrTrunc(PreferredVecIdxWidth);`
 ->
`APInt NewIdx = CI->getValue().zextOrTrunc(PreferredVecIdxWidth);`

Language ref does not specify required type for index, although we probably expected i32,
vector in test `%I` has two elements and i1 is enough to hold index, so globalisel should probably treat `i1` `true` and `false` as `0` and `1` i32 indices .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132938/new/

https://reviews.llvm.org/D132938



More information about the llvm-commits mailing list