-
Notifications
You must be signed in to change notification settings - Fork 12.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IrTranslator] Sign extends index value for G_EXTRACT_VECTOR_ELT, translating i1 true
into i32 -1
.
#57452
Labels
Comments
See patch: https://reviews.llvm.org/D132978 |
DataCorrupted
added a commit
that referenced
this issue
Oct 15, 2022
In #57452, we found that IRTranslator is translating `i1 true` into `i32 -1`. This is because IRTranslator uses SExt for indices. In this fix, we change the expected behavior of extractelement's index, moving from SExt to ZExt. This change includes both documentation, SelectionDAG and IRTranslator. We also included a test for AMDGPU, updated tests for AArch64, Mips, PowerPC, RISCV, VE, WebAssembly and X86 This patch fixes issue #57452. Differential Revision: https://reviews.llvm.org/D132978
Has been fixed and merged in commit c2e7c9cb33ac |
sid8123
pushed a commit
to sid8123/llvm-project
that referenced
this issue
Oct 25, 2022
In llvm#57452, we found that IRTranslator is translating `i1 true` into `i32 -1`. This is because IRTranslator uses SExt for indices. In this fix, we change the expected behavior of extractelement's index, moving from SExt to ZExt. This change includes both documentation, SelectionDAG and IRTranslator. We also included a test for AMDGPU, updated tests for AArch64, Mips, PowerPC, RISCV, VE, WebAssembly and X86 This patch fixes issue llvm#57452. Differential Revision: https://reviews.llvm.org/D132978
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an issue related to #57408
Given the following seed and command. Or you can see the result here: https://llvm.godbolt.org/z/dd5edjrG3
Regardless the architecture, IrTranslator will translate the index
i1 true
into%9:_(s64) = G_CONSTANT i64 -1
(ors32 -1
on 32bit architecture).This has caused AMDGPU backend to crash since negative index is unexpected. (See #57408 )
Further study shows that we are sign extending the index at IRTranslator.cpp:2811, thus given values like
i1 true
,i8 255
, the index will be translated as -1.We propose this change
as mentioned by @petar-avramovic in the latest review: https://reviews.llvm.org/D132938
The text was updated successfully, but these errors were encountered: