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
InstCombine incorrectly folds 'gep(bitcast ptr), idx' into 'gep ptr, idx' #43666
Comments
The t |
Sorry for my mistake :( |
I agree this is a bug. |
I introduced the bug here: Using weird types in the tests helped expose it. In the common case where we have a power-of-2 vector/array and the alloc-sizes are the same, I think the transform should still be ok. I'll post a patch for review. |
Should be fixed with: |
Lost some chars on that link: |
Extended Description
This is incorrect because DataLayout::getTypeAllocSize(< 7 x i32 >) and getTypeAllocSize([ 7 x i32 ]) may differ.
This can be double-checked by emitting assembly code before/after optimization.
https://godbolt.org/z/xB-p5u
Before optimization, rax = rdi + 28 * rsi + 4 * rdx
After instcombine, rax = rdi + 32 * rsi + 4 * rdx.
The text was updated successfully, but these errors were encountered: