llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.77k stars 11.89k forks source link

[AMDGPU] Uses SExt on indices in `isInterestingPHIIncomingValue` #85717

Closed DataCorrupted closed 7 months ago

DataCorrupted commented 7 months ago

Reproduction

https://godbolt.org/z/P97TT7fEs

Cause

When i1 true is used as an index, SExt extends it to i32 -1. This would cause BitVector to overflow. This can be a quick fix by using ZExt over SExt, as we have specified in the language manual that the index shall be treated as an unsigned number. (https://llvm.org/docs/LangRef.html#insertelement-instruction)

llvmbot commented 7 months ago

@llvm/issue-subscribers-backend-amdgpu

Author: Peter Rong (DataCorrupted)

## Reproduction https://godbolt.org/z/P97TT7fEs ## Cause When `i1 true` is used as an index, SExt extends it to `i32 -1`. This would cause BitVector to overflow. This can be a quick fix by using ZExt over SExt, as we have specified in the language manual that the index shall be treated as an unsigned number. (https://llvm.org/docs/LangRef.html#insertelement-instruction)