[llvm-bugs] [Bug 44321] New: InstCombine incorrectly folds 'gep(bitcast ptr), idx' into 'gep ptr, idx'
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 17 04:59:58 PST 2019
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: unassignedbugs at nondot.org
Reporter: juneyoung.lee at sf.snu.ac.kr
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191217/7c3b2a66/attachment-0001.html>
More information about the llvm-bugs
mailing list