File: cross.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (56 lines) | stat: -rw-r--r-- 2,609 bytes parent folder | download | duplicates (2)
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
; RUN: opt -S  -dxil-intrinsic-expansion  < %s | FileCheck %s

; Make sure dxil operation function calls for cross are generated for half/float.

declare <3 x half> @llvm.dx.cross.v3f16(<3 x half>, <3 x half>)
declare <3 x float> @llvm.dx.cross.v3f32(<3 x float>, <3 x float>)

define noundef <3 x half> @test_cross_half3(<3 x half> noundef %p0, <3 x half> noundef %p1) {
entry:
  ; CHECK: %x0 = extractelement <3 x half> %p0, i64 0
  ; CHECK: %x1 = extractelement <3 x half> %p0, i64 1
  ; CHECK: %x2 = extractelement <3 x half> %p0, i64 2
  ; CHECK: %y0 = extractelement <3 x half> %p1, i64 0
  ; CHECK: %y1 = extractelement <3 x half> %p1, i64 1
  ; CHECK: %y2 = extractelement <3 x half> %p1, i64 2
  ; CHECK: %0 = fmul half %x1, %y2
  ; CHECK: %1 = fmul half %x2, %y1
  ; CHECK: %hlsl.cross1 = fsub half %0, %1
  ; CHECK: %2 = fmul half %x2, %y0
  ; CHECK: %3 = fmul half %x0, %y2
  ; CHECK: %hlsl.cross2 = fsub half %2, %3
  ; CHECK: %4 = fmul half %x0, %y1
  ; CHECK: %5 = fmul half %x1, %y0
  ; CHECK: %hlsl.cross3 = fsub half %4, %5
  ; CHECK: %6 = insertelement <3 x half> undef, half %hlsl.cross1, i64 0
  ; CHECK: %7 = insertelement <3 x half> %6, half %hlsl.cross2, i64 1
  ; CHECK: %8 = insertelement <3 x half> %7, half %hlsl.cross3, i64 2
  ; CHECK: ret <3 x half> %8
  %hlsl.cross = call <3 x half> @llvm.dx.cross.v3f16(<3 x half> %p0, <3 x half> %p1)
  ret <3 x half> %hlsl.cross
}

define noundef <3 x float> @test_cross_float3(<3 x float> noundef %p0, <3 x float> noundef %p1) {
entry:
  ; CHECK: %x0 = extractelement <3 x float> %p0, i64 0
  ; CHECK: %x1 = extractelement <3 x float> %p0, i64 1
  ; CHECK: %x2 = extractelement <3 x float> %p0, i64 2
  ; CHECK: %y0 = extractelement <3 x float> %p1, i64 0
  ; CHECK: %y1 = extractelement <3 x float> %p1, i64 1
  ; CHECK: %y2 = extractelement <3 x float> %p1, i64 2
  ; CHECK: %0 = fmul float %x1, %y2
  ; CHECK: %1 = fmul float %x2, %y1
  ; CHECK: %hlsl.cross1 = fsub float %0, %1
  ; CHECK: %2 = fmul float %x2, %y0
  ; CHECK: %3 = fmul float %x0, %y2
  ; CHECK: %hlsl.cross2 = fsub float %2, %3
  ; CHECK: %4 = fmul float %x0, %y1
  ; CHECK: %5 = fmul float %x1, %y0
  ; CHECK: %hlsl.cross3 = fsub float %4, %5
  ; CHECK: %6 = insertelement <3 x float> undef, float %hlsl.cross1, i64 0
  ; CHECK: %7 = insertelement <3 x float> %6, float %hlsl.cross2, i64 1
  ; CHECK: %8 = insertelement <3 x float> %7, float %hlsl.cross3, i64 2
  ; CHECK: ret <3 x float> %8
  %hlsl.cross = call <3 x float> @llvm.dx.cross.v3f32(<3 x float> %p0, <3 x float> %p1)
  ret <3 x float> %hlsl.cross
}