mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 17:26:06 +00:00

Per LangRef: > The offsets are then added to the low bits of the base address up to the index type width, with silently-wrapping two’s complement arithmetic. If the pointer size is larger than the index size, this means that the bits outside the index type width will not be affected. The transform as implemented was doubly wrong, because it just truncated the original base pointer to the index width, losing the top bits entirely. Make sure we preserve the bits and use wrapping arithmetic within the low bits.
15 lines
452 B
LLVM
15 lines
452 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
|
|
; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
|
|
|
|
target datalayout = "p:16:16:16:8"
|
|
|
|
; The GEP should only modify the low 8 bits of the pointer.
|
|
define ptr @test() {
|
|
; CHECK-LABEL: define ptr @test() {
|
|
; CHECK-NEXT: ret ptr inttoptr (i16 -256 to ptr)
|
|
;
|
|
%base = inttoptr i16 -1 to ptr
|
|
%gep = getelementptr i8, ptr %base, i8 1
|
|
ret ptr %gep
|
|
}
|