File: v-binop-widen2.ll

package info (click to toggle)
llvm-toolchain-3.4 1%3A3.4.2-13
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 253,236 kB
  • ctags: 276,203
  • sloc: cpp: 1,665,580; ansic: 298,647; asm: 206,157; objc: 84,350; python: 73,119; sh: 23,466; perl: 5,679; makefile: 5,542; ml: 5,250; pascal: 2,467; lisp: 1,420; xml: 679; cs: 236; csh: 117
file content (47 lines) | stat: -rw-r--r-- 1,419 bytes parent folder | download | duplicates (3)
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
; RUN: llc -march=x86 -mcpu=generic -mattr=+sse < %s | FileCheck %s
; RUN: llc -march=x86 -mcpu=atom -mattr=+sse < %s | FileCheck -check-prefix=ATOM %s

%vec = type <6 x float>
; CHECK: divps
; CHECK: divss
; CHECK: divss

; Scheduler causes a different instruction order to be produced on Intel Atom
; ATOM: divps
; ATOM: divss
; ATOM: divss

define %vec @vecdiv( %vec %p1, %vec %p2)
{
  %result = fdiv %vec %p1, %p2
  ret %vec %result
}

@a = constant %vec < float 2.0, float 4.0, float 8.0, float 16.0, float 32.0, float 64.0 >
@b = constant %vec < float 2.0, float 2.0, float 2.0, float 2.0, float 2.0, float 2.0 >

; Expected result: < 1.0, 2.0, 4.0, ..., 2.0^(n-1) >
; main() returns 0 if the result is expected and 1 otherwise
; to execute, use llvm-as < %s | lli
define i32 @main() nounwind {
entry:
  %avec = load %vec* @a
  %bvec = load %vec* @b

  %res = call %vec @vecdiv(%vec %avec, %vec %bvec)
  br label %loop
loop:
  %idx = phi i32 [0, %entry], [%nextInd, %looptail]
  %expected = phi float [1.0, %entry], [%nextExpected, %looptail]
  %elem = extractelement %vec %res, i32 %idx
  %expcmp = fcmp oeq float %elem, %expected
  br i1 %expcmp, label %looptail, label %return
looptail:
  %nextExpected = fmul float %expected, 2.0
  %nextInd = add i32 %idx, 1
  %cmp = icmp slt i32 %nextInd, 6
  br i1 %cmp, label %loop, label %return
return:
  %retval = phi i32 [0, %looptail], [1, %loop]
  ret i32 %retval
}