1; Test integer negation.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Test i32->i32 negation.
6define i32 @f1(i32 %val) {
7; CHECK-LABEL: f1:
8; CHECK: lcr %r2, %r2
9; CHECK: br %r14
10  %neg = sub i32 0, %val
11  ret i32 %neg
12}
13
14; Test i32->i64 negation.
15define i64 @f2(i32 %val) {
16; CHECK-LABEL: f2:
17; CHECK: lcgfr %r2, %r2
18; CHECK: br %r14
19  %ext = sext i32 %val to i64
20  %neg = sub i64 0, %ext
21  ret i64 %neg
22}
23
24; Test i32->i64 negation that uses an "in-register" form of sign extension.
25define i64 @f3(i64 %val) {
26; CHECK-LABEL: f3:
27; CHECK: lcgfr %r2, %r2
28; CHECK: br %r14
29  %trunc = trunc i64 %val to i32
30  %ext = sext i32 %trunc to i64
31  %neg = sub i64 0, %ext
32  ret i64 %neg
33}
34
35; Test i64 negation.
36define i64 @f4(i64 %val) {
37; CHECK-LABEL: f4:
38; CHECK: lcgr %r2, %r2
39; CHECK: br %r14
40  %neg = sub i64 0, %val
41  ret i64 %neg
42}
43