https://bugs.llvm.org/show_bug.cgi?id=44321
Bug ID: 44321
Summary: InstCombine incorrectly folds 'gep(bitcast ptr), idx'
into 'gep ptr, idx'
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
Assignee: unassignedb...@nondot.org
Reporter: juneyoung....@sf.snu.ac.kr
CC: llvm-bugs@lists.llvm.org
```
$ cat gep-vector.ll
define i32* @bitcast_vec_to_array_gep(<7 x i32>* %x, i64 %y, i64 %z) {
%arr_ptr = bitcast <7 x i32>* %x to [7 x i32]*
%gep = getelementptr [7 x i32], [7 x i32]* %arr_ptr, i64 %y, i64 %z
ret i32* %gep
}
$ opt -instcombine gep-vector.ll -S -o -
define i32* @bitcast_vec_to_array_gep(<7 x i32>* %x, i64 %y, i64 %z) {
%gep = getelementptr <7 x i32>, <7 x i32>* %x, i64 %y, i64 %z
ret i32* %gep
}
```
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs