1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/test/Transforms/Inline/gep_from_constant.ll
Kirill Naumov 056922ee41 [InlineCost] GetElementPtr with constant operands
If the GEP instruction contanins only constants as its arguments,
then it should be recognized as a constant. For now, there was
also added a flag to turn off this simplification if it causes
any regressions ("disable-gep-const-evaluation") which is off
by default. Once I gather needed data of the effectiveness of
this simplification, the flag will be deleted.

Reviewers: apilipenko, davidxl, mtrofin

Reviewed By: mtrofin

Differential Revision: https://reviews.llvm.org/D81026
2020-06-25 18:09:51 +00:00

16 lines
645 B
LLVM

; RUN: opt < %s -passes="print<inline-cost>" 2>&1 | FileCheck %s
; CHECK-LABEL: @foo
; CHECK: cost before = {{.*}}, cost after = {{.*}}, threshold before = {{.*}}, threshold after = {{.*}}, cost delta = {{.*}}, simplified to i8 addrspace(1)** getelementptr (i8 addrspace(1)*, i8 addrspace(1)** inttoptr (i64 754974720 to i8 addrspace(1)**), i64 5)
define i8 addrspace(1)** @foo(i64 %0) {
%2 = inttoptr i64 754974720 to i8 addrspace(1)**
%3 = getelementptr i8 addrspace(1)*, i8 addrspace(1)** %2, i64 %0
ret i8 addrspace(1)** %3
}
define i8 addrspace(1)** @main() {
%1 = call i8 addrspace(1)** @foo(i64 5)
ret i8 addrspace(1)** %1
}