1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ndd -verify-machineinstrs | FileCheck %s
4 define i8 @neg8r(i8 noundef %a) {
6 ; CHECK: # %bb.0: # %entry
7 ; CHECK-NEXT: negb %dil, %al
14 define i16 @neg16r(i16 noundef %a) {
15 ; CHECK-LABEL: neg16r:
16 ; CHECK: # %bb.0: # %entry
17 ; CHECK-NEXT: negl %edi, %eax
18 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
25 define i32 @neg32r(i32 noundef %a) {
26 ; CHECK-LABEL: neg32r:
27 ; CHECK: # %bb.0: # %entry
28 ; CHECK-NEXT: negl %edi, %eax
35 define i64 @neg64r(i64 noundef %a) {
36 ; CHECK-LABEL: neg64r:
37 ; CHECK: # %bb.0: # %entry
38 ; CHECK-NEXT: negq %rdi, %rax
45 define i8 @neg8m(ptr %ptr) {
47 ; CHECK: # %bb.0: # %entry
48 ; CHECK-NEXT: negb (%rdi), %al
51 %a = load i8, ptr %ptr
56 define i16 @neg16m(ptr %ptr) {
57 ; CHECK-LABEL: neg16m:
58 ; CHECK: # %bb.0: # %entry
59 ; CHECK-NEXT: negw (%rdi), %ax
62 %a = load i16, ptr %ptr
67 define i32 @neg32m(ptr %ptr) {
68 ; CHECK-LABEL: neg32m:
69 ; CHECK: # %bb.0: # %entry
70 ; CHECK-NEXT: negl (%rdi), %eax
73 %a = load i32, ptr %ptr
78 define i64 @neg64m(ptr %ptr) {
79 ; CHECK-LABEL: neg64m:
80 ; CHECK: # %bb.0: # %entry
81 ; CHECK-NEXT: negq (%rdi), %rax
84 %a = load i64, ptr %ptr
89 define i8 @uneg8r(i8 noundef %a) {
90 ; CHECK-LABEL: uneg8r:
91 ; CHECK: # %bb.0: # %entry
92 ; CHECK-NEXT: negb %dil, %al
95 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 0, i8 %a)
96 %neg = extractvalue {i8, i1} %t, 0
100 define i16 @uneg16r(i16 noundef %a) {
101 ; CHECK-LABEL: uneg16r:
102 ; CHECK: # %bb.0: # %entry
103 ; CHECK-NEXT: negl %edi, %eax
104 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
107 %t = call {i16, i1} @llvm.usub.with.overflow.i16(i16 0, i16 %a)
108 %neg = extractvalue {i16, i1} %t, 0
112 define i32 @uneg32r(i32 noundef %a) {
113 ; CHECK-LABEL: uneg32r:
114 ; CHECK: # %bb.0: # %entry
115 ; CHECK-NEXT: negl %edi, %eax
118 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 0, i32 %a)
119 %neg = extractvalue {i32, i1} %t, 0
123 define i64 @uneg64r(i64 noundef %a) {
124 ; CHECK-LABEL: uneg64r:
125 ; CHECK: # %bb.0: # %entry
126 ; CHECK-NEXT: negq %rdi, %rax
129 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 0, i64 %a)
130 %neg = extractvalue {i64, i1} %t, 0
134 define i8 @uneg8m(ptr %ptr) {
135 ; CHECK-LABEL: uneg8m:
136 ; CHECK: # %bb.0: # %entry
137 ; CHECK-NEXT: negb (%rdi), %al
140 %a = load i8, ptr %ptr
141 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 0, i8 %a)
142 %neg = extractvalue {i8, i1} %t, 0
146 define i16 @uneg16m(ptr %ptr) {
147 ; CHECK-LABEL: uneg16m:
148 ; CHECK: # %bb.0: # %entry
149 ; CHECK-NEXT: negw (%rdi), %ax
152 %a = load i16, ptr %ptr
153 %t = call {i16, i1} @llvm.usub.with.overflow.i16(i16 0, i16 %a)
154 %neg = extractvalue {i16, i1} %t, 0
158 define i32 @uneg32m(ptr %ptr) {
159 ; CHECK-LABEL: uneg32m:
160 ; CHECK: # %bb.0: # %entry
161 ; CHECK-NEXT: negl (%rdi), %eax
164 %a = load i32, ptr %ptr
165 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 0, i32 %a)
166 %neg = extractvalue {i32, i1} %t, 0
170 define i64 @uneg64m(ptr %ptr) {
171 ; CHECK-LABEL: uneg64m:
172 ; CHECK: # %bb.0: # %entry
173 ; CHECK-NEXT: negq (%rdi), %rax
176 %a = load i64, ptr %ptr
177 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 0, i64 %a)
178 %neg = extractvalue {i64, i1} %t, 0
182 declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8)
183 declare {i16, i1} @llvm.usub.with.overflow.i16(i16, i16)
184 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32)
185 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64)
187 define void @neg8m_legacy(ptr %ptr) {
188 ; CHECK-LABEL: neg8m_legacy:
189 ; CHECK: # %bb.0: # %entry
190 ; CHECK-NEXT: negb (%rdi)
193 %a = load i8, ptr %ptr
195 store i8 %neg, ptr %ptr
199 define void @neg16m_legacy(ptr %ptr) {
200 ; CHECK-LABEL: neg16m_legacy:
201 ; CHECK: # %bb.0: # %entry
202 ; CHECK-NEXT: negw (%rdi)
205 %a = load i16, ptr %ptr
207 store i16 %neg, ptr %ptr
211 define void @neg32m_legacy(ptr %ptr) {
212 ; CHECK-LABEL: neg32m_legacy:
213 ; CHECK: # %bb.0: # %entry
214 ; CHECK-NEXT: negl (%rdi)
217 %a = load i32, ptr %ptr
219 store i32 %neg, ptr %ptr
223 define void @neg64m_legacy(ptr %ptr) {
224 ; CHECK-LABEL: neg64m_legacy:
225 ; CHECK: # %bb.0: # %entry
226 ; CHECK-NEXT: negq (%rdi)
229 %a = load i64, ptr %ptr
231 store i64 %neg, ptr %ptr