1; RUN: opt < %s -instsimplify -S | FileCheck %s 2 3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-unknown-linux-gnu" 5 6@a = external global i8 7@b = external global i8 8 9@c1 = constant i32 trunc (i64 sub (i64 ptrtoint (i8* @a to i64), i64 ptrtoint (i32* @c1 to i64)) to i32) 10@c2 = constant [7 x i32] [i32 0, i32 0, 11i32 trunc (i64 sub (i64 ptrtoint (i8* @a to i64), i64 ptrtoint (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i32 0, i32 2) to i64)) to i32), 12i32 trunc (i64 sub (i64 ptrtoint (i8* @b to i64), i64 ptrtoint (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i32 0, i32 2) to i64)) to i32), 13i32 trunc (i64 add (i64 ptrtoint (i8* @b to i64), i64 ptrtoint (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i32 0, i32 2) to i64)) to i32), 14i32 trunc (i64 sub (i64 ptrtoint (i8* @b to i64), i64 1) to i32), 15i32 trunc (i64 sub (i64 0, i64 ptrtoint (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i32 0, i32 2) to i64)) to i32) 16] 17 18; CHECK: @f1 19define i8* @f1() { 20 ; CHECK: ret i8* @a 21 %l = call i8* @llvm.load.relative.i32(i8* bitcast (i32* @c1 to i8*), i32 0) 22 ret i8* %l 23} 24 25; CHECK: @f2 26define i8* @f2() { 27 ; CHECK: ret i8* @a 28 %l = call i8* @llvm.load.relative.i32(i8* bitcast (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i64 0, i64 2) to i8*), i32 0) 29 ret i8* %l 30} 31 32; CHECK: @f3 33define i8* @f3() { 34 ; CHECK: ret i8* @b 35 %l = call i8* @llvm.load.relative.i64(i8* bitcast (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i64 0, i64 2) to i8*), i64 4) 36 ret i8* %l 37} 38 39; CHECK: @f4 40define i8* @f4() { 41 ; CHECK: ret i8* % 42 %l = call i8* @llvm.load.relative.i32(i8* bitcast (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i64 0, i64 2) to i8*), i32 1) 43 ret i8* %l 44} 45 46; CHECK: @f5 47define i8* @f5() { 48 ; CHECK: ret i8* % 49 %l = call i8* @llvm.load.relative.i32(i8* zeroinitializer, i32 0) 50 ret i8* %l 51} 52 53; CHECK: @f6 54define i8* @f6() { 55 ; CHECK: ret i8* % 56 %l = call i8* @llvm.load.relative.i32(i8* bitcast (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i64 0, i64 2) to i8*), i32 8) 57 ret i8* %l 58} 59 60; CHECK: @f7 61define i8* @f7() { 62 ; CHECK: ret i8* % 63 %l = call i8* @llvm.load.relative.i32(i8* bitcast (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i64 0, i64 2) to i8*), i32 12) 64 ret i8* %l 65} 66 67; CHECK: @f8 68define i8* @f8() { 69 ; CHECK: ret i8* % 70 %l = call i8* @llvm.load.relative.i32(i8* bitcast (i32* getelementptr ([7 x i32], [7 x i32]* @c2, i64 0, i64 2) to i8*), i32 16) 71 ret i8* %l 72} 73 74declare i8* @llvm.load.relative.i32(i8*, i32) 75declare i8* @llvm.load.relative.i64(i8*, i64) 76