Debian Codegraph @

llvm/test/CodeGen/PowerPC/vec_add_sub_doubleword.ll

raw
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s --check-prefixes=ALL,VSX
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 -mattr=-vsx < %s | FileCheck %s --check-prefixes=ALL,NOVSX
4
5 ; Check VMX 64-bit integer operations
6
7 define <2 x i64> @test_add(<2 x i64> %x, <2 x i64> %y) nounwind {
8 ; ALL-LABEL: test_add:
9 ; ALL: # %bb.0:
10 ; ALL-NEXT: vaddudm 2, 2, 3
11 ; ALL-NEXT: blr
12 %result = add <2 x i64> %x, %y
13 ret <2 x i64> %result
14 }
15
16 define <2 x i64> @increment_by_one(<2 x i64> %x) nounwind {
17 ; VSX-LABEL: increment_by_one:
18 ; VSX: # %bb.0:
19 ; VSX-NEXT: xxleqv 35, 35, 35
20 ; VSX-NEXT: vsubudm 2, 2, 3
21 ; VSX-NEXT: blr
22 ;
23 ; NOVSX-LABEL: increment_by_one:
24 ; NOVSX: # %bb.0:
25 ; NOVSX-NEXT: addis 3, 2, .LCPI1_0@toc@ha
26 ; NOVSX-NEXT: addi 3, 3, .LCPI1_0@toc@l
27 ; NOVSX-NEXT: lvx 3, 0, 3
28 ; NOVSX-NEXT: vaddudm 2, 2, 3
29 ; NOVSX-NEXT: blr
30 %result = add <2 x i64> %x, <i64 1, i64 1>
31 ret <2 x i64> %result
32 }
33
34 define <2 x i64> @increment_by_val(<2 x i64> %x, i64 %val) nounwind {
35 ; VSX-LABEL: increment_by_val:
36 ; VSX: # %bb.0:
37 ; VSX-NEXT: mtfprd 0, 5
38 ; VSX-NEXT: xxspltd 35, 0, 0
39 ; VSX-NEXT: vaddudm 2, 2, 3
40 ; VSX-NEXT: blr
41 ;
42 ; NOVSX-LABEL: increment_by_val:
43 ; NOVSX: # %bb.0:
44 ; NOVSX-NEXT: addi 3, 1, -16
45 ; NOVSX-NEXT: std 5, -8(1)
46 ; NOVSX-NEXT: std 5, -16(1)
47 ; NOVSX-NEXT: lvx 3, 0, 3
48 ; NOVSX-NEXT: vaddudm 2, 2, 3
49 ; NOVSX-NEXT: blr
50 %tmpvec = insertelement <2 x i64> <i64 0, i64 0>, i64 %val, i32 0
51 %tmpvec2 = insertelement <2 x i64> %tmpvec, i64 %val, i32 1
52 %result = add <2 x i64> %x, %tmpvec2
53 ret <2 x i64> %result
54 ; FIXME: This is currently generating the following instruction sequence
55 ; std 5, -8(1)
56 ; std 5, -16(1)
57 ; addi 3, 1, -16
58 ; ori 2, 2, 0
59 ; lxvd2x 35, 0, 3
60 ; vaddudm 2, 2, 3
61 ; blr
62 ; This will almost certainly cause a load-hit-store hazard.
63 ; Since val is a value parameter, it should not need to be
64 ; saved onto the stack at all (unless we're using this to set
65 ; up the vector register). Instead, it would be better to splat
66 ; the value into a vector register.
67 }
68
69 define <2 x i64> @test_sub(<2 x i64> %x, <2 x i64> %y) nounwind {
70 ; ALL-LABEL: test_sub:
71 ; ALL: # %bb.0:
72 ; ALL-NEXT: vsubudm 2, 2, 3
73 ; ALL-NEXT: blr
74 %result = sub <2 x i64> %x, %y
75 ret <2 x i64> %result
76 }
77
78 define <2 x i64> @decrement_by_one(<2 x i64> %x) nounwind {
79 ; VSX-LABEL: decrement_by_one:
80 ; VSX: # %bb.0:
81 ; VSX-NEXT: xxleqv 35, 35, 35
82 ; VSX-NEXT: vsubudm 2, 2, 3
83 ; VSX-NEXT: blr
84 ;
85 ; NOVSX-LABEL: decrement_by_one:
86 ; NOVSX: # %bb.0:
87 ; NOVSX-NEXT: addis 3, 2, .LCPI4_0@toc@ha
88 ; NOVSX-NEXT: addi 3, 3, .LCPI4_0@toc@l
89 ; NOVSX-NEXT: lvx 3, 0, 3
90 ; NOVSX-NEXT: vsubudm 2, 2, 3
91 ; NOVSX-NEXT: blr
92 %result = sub <2 x i64> %x, <i64 -1, i64 -1>
93 ret <2 x i64> %result
94 }
95
96 define <2 x i64> @decrement_by_val(<2 x i64> %x, i64 %val) nounwind {
97 ; VSX-LABEL: decrement_by_val:
98 ; VSX: # %bb.0:
99 ; VSX-NEXT: mtfprd 0, 5
100 ; VSX-NEXT: xxspltd 35, 0, 0
101 ; VSX-NEXT: vsubudm 2, 2, 3
102 ; VSX-NEXT: blr
103 ;
104 ; NOVSX-LABEL: decrement_by_val:
105 ; NOVSX: # %bb.0:
106 ; NOVSX-NEXT: addi 3, 1, -16
107 ; NOVSX-NEXT: std 5, -8(1)
108 ; NOVSX-NEXT: std 5, -16(1)
109 ; NOVSX-NEXT: lvx 3, 0, 3
110 ; NOVSX-NEXT: vsubudm 2, 2, 3
111 ; NOVSX-NEXT: blr
112 %tmpvec = insertelement <2 x i64> <i64 0, i64 0>, i64 %val, i32 0
113 %tmpvec2 = insertelement <2 x i64> %tmpvec, i64 %val, i32 1
114 %result = sub <2 x i64> %x, %tmpvec2
115 ret <2 x i64> %result
116 }