1 ; RUN: opt -instcombine -S -o - %s | FileCheck %s
\r
2 ; Tests that we preserve the inrange attribute on indices where possible.
\r
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
\r
5 target triple = "x86_64-unknown-linux-gnu"
\r
7 %struct.A = type { i32 (...)** }
\r
9 @vt = external global [3 x i8*]
\r
11 ; CHECK: define i32 (...)** @f0()
\r
12 define i32 (...)** @f0() {
\r
13 ; CHECK-NEXT: ret i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 2) to i32 (...)**
\r
14 ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 1) to i32 (...)**), i64 1)
\r
17 ; CHECK: define i32 (...)** @f1()
\r
18 define i32 (...)** @f1() {
\r
19 ; CHECK-NEXT: ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
\r
20 ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
\r
23 ; CHECK: define i32 (...)** @f2()
\r
24 define i32 (...)** @f2() {
\r
25 ; CHECK-NEXT: ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
\r
26 ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
\r