File: mem-gep-zidx.ll

package info (click to toggle)
llvm-toolchain-7 1%3A7.0.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 733,456 kB
  • sloc: cpp: 3,776,651; ansic: 633,271; asm: 350,301; python: 142,716; objc: 107,612; sh: 22,626; lisp: 11,056; perl: 7,999; pascal: 6,742; ml: 5,537; awk: 3,536; makefile: 2,557; cs: 2,027; xml: 841; ruby: 156
file content (60 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
; RUN: opt -S -instcombine < %s | FileCheck %s
target datalayout = "E-m:e-i64:64-n32:64"
target triple = "powerpc64-unknown-linux-gnu"

@f.a = private unnamed_addr constant [1 x i32] [i32 12], align 4
@f.b = private unnamed_addr constant [1 x i32] [i32 55], align 4
@f.c = linkonce unnamed_addr alias [1 x i32], [1 x i32]* @f.b

define signext i32 @test1(i32 signext %x) #0 {
entry:
  %idxprom = sext i32 %x to i64
  %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @f.a, i64 0, i64 %idxprom
  %0 = load i32, i32* %arrayidx, align 4
  ret i32 %0

; CHECK-LABEL: @test1
; CHECK: ret i32 12
}

declare void @foo(i64* %p)
define void @test2(i32 signext %x, i64 %v) #0 {
entry:
  %p = alloca i64
  %idxprom = sext i32 %x to i64
  %arrayidx = getelementptr inbounds i64, i64* %p, i64 %idxprom
  store i64 %v, i64* %arrayidx
  call void @foo(i64* %p)
  ret void

; CHECK-LABEL: @test2
; CHECK: %p = alloca i64
; CHECK: store i64 %v, i64* %p
; CHECK: ret void
}

define signext i32 @test3(i32 signext %x, i1 %y) #0 {
entry:
  %idxprom = sext i32 %x to i64
  %p = select i1 %y, [1 x i32]* @f.a, [1 x i32]* @f.b
  %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* %p, i64 0, i64 %idxprom
  %0 = load i32, i32* %arrayidx, align 4
  ret i32 %0

; CHECK-LABEL: @test3
; CHECK: getelementptr inbounds [1 x i32], [1 x i32]* %p, i64 0, i64 0
}

define signext i32 @test4(i32 signext %x, i1 %y) #0 {
entry:
  %idxprom = sext i32 %x to i64
  %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @f.c, i64 0, i64 %idxprom
  %0 = load i32, i32* %arrayidx, align 4
  ret i32 %0

; CHECK-LABEL: @test4
; CHECK: getelementptr inbounds [1 x i32], [1 x i32]* @f.c, i64 0, i64 %idxprom
}

attributes #0 = { nounwind readnone }