File: 2008-09-22-vector-gep.ll

package info (click to toggle)
llvm 2.6-9.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 57,604 kB
  • ctags: 44,336
  • sloc: cpp: 344,766; sh: 12,407; ansic: 10,617; ada: 3,070; ml: 2,505; perl: 2,496; makefile: 1,426; pascal: 1,163; exp: 389; asm: 307; python: 298; objc: 260; lisp: 182; csh: 117; xml: 38; f90: 36; tcl: 20
file content (24 lines) | stat: -rw-r--r-- 986 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
; This test checks to see if scalarrepl also works when a gep with all zeroes is
; used instead of a bitcast to prepare a memmove pointer argument. Previously,
; this would not work when there was a vector involved in the struct, preventing
; scalarrepl from removing the alloca below.

; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis > %t
; RUN: cat %t | not grep alloca

%struct.two = type <{ < 2 x i8 >, i16 }>

define void @main(%struct.two* %D, i16 %V) {
entry:
	%S = alloca %struct.two
        %S.2 = getelementptr %struct.two* %S, i32 0, i32 1
        store i16 %V, i16* %S.2
        ; This gep is effectively a bitcast to i8*, but is sometimes generated
        ; because the type of the first element in %struct.two is i8.
	%tmpS = getelementptr %struct.two* %S, i32 0, i32 0, i32 0 
	%tmpD = bitcast %struct.two* %D to i8*
        call void @llvm.memmove.i32(i8* %tmpD, i8* %tmpS, i32 4, i32 1)
        ret void
}

declare void @llvm.memmove.i32(i8*, i8*, i32, i32) nounwind