Skip to content

Commit a875030

Browse files
committedOct 9, 2018
[AArch64][x86] add tests for bitcasted fnabs; NFC
Alternate target coverage for D44548. llvm-svn: 344059
1 parent c968c98 commit a875030

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
 

‎llvm/test/CodeGen/AArch64/fabs.ll

+50
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,55 @@ define float @still_not_fabs(float %x) #0 {
3434
ret float %cond
3535
}
3636

37+
define float @nabsf(float %a) {
38+
; CHECK-LABEL: nabsf:
39+
; CHECK: // %bb.0:
40+
; CHECK-NEXT: fmov w8, s0
41+
; CHECK-NEXT: orr w8, w8, #0x80000000
42+
; CHECK-NEXT: fmov s0, w8
43+
; CHECK-NEXT: ret
44+
%conv = bitcast float %a to i32
45+
%and = or i32 %conv, -2147483648
46+
%conv1 = bitcast i32 %and to float
47+
ret float %conv1
48+
}
49+
50+
define double @nabsd(double %a) {
51+
; CHECK-LABEL: nabsd:
52+
; CHECK: // %bb.0:
53+
; CHECK-NEXT: fmov x8, d0
54+
; CHECK-NEXT: orr x8, x8, #0x8000000000000000
55+
; CHECK-NEXT: fmov d0, x8
56+
; CHECK-NEXT: ret
57+
%conv = bitcast double %a to i64
58+
%and = or i64 %conv, -9223372036854775808
59+
%conv1 = bitcast i64 %and to double
60+
ret double %conv1
61+
}
62+
63+
define <4 x float> @nabsv4f32(<4 x float> %a) {
64+
; CHECK-LABEL: nabsv4f32:
65+
; CHECK: // %bb.0:
66+
; CHECK-NEXT: orr v0.4s, #128, lsl #24
67+
; CHECK-NEXT: ret
68+
%conv = bitcast <4 x float> %a to <4 x i32>
69+
%and = or <4 x i32> %conv, <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>
70+
%conv1 = bitcast <4 x i32> %and to <4 x float>
71+
ret <4 x float> %conv1
72+
}
73+
74+
define <2 x double> @nabsv2d64(<2 x double> %a) {
75+
; CHECK-LABEL: nabsv2d64:
76+
; CHECK: // %bb.0:
77+
; CHECK-NEXT: orr x8, xzr, #0x8000000000000000
78+
; CHECK-NEXT: dup v1.2d, x8
79+
; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
80+
; CHECK-NEXT: ret
81+
%conv = bitcast <2 x double> %a to <2 x i64>
82+
%and = or <2 x i64> %conv, <i64 -9223372036854775808, i64 -9223372036854775808>
83+
%conv1 = bitcast <2 x i64> %and to <2 x double>
84+
ret <2 x double> %conv1
85+
}
86+
3787
attributes #0 = { "no-nans-fp-math"="true" }
3888

‎llvm/test/CodeGen/X86/fp-logic.ll

+46
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,52 @@ define float @fsub_bitcast_fneg(float %x, float %y) {
308308
ret float %fsub
309309
}
310310

311+
define float @nabsf(float %a) {
312+
; CHECK-LABEL: nabsf:
313+
; CHECK: # %bb.0:
314+
; CHECK-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
315+
; CHECK-NEXT: orps %xmm1, %xmm0
316+
; CHECK-NEXT: retq
317+
%conv = bitcast float %a to i32
318+
%and = or i32 %conv, -2147483648
319+
%conv1 = bitcast i32 %and to float
320+
ret float %conv1
321+
}
322+
323+
define double @nabsd(double %a) {
324+
; CHECK-LABEL: nabsd:
325+
; CHECK: # %bb.0:
326+
; CHECK-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
327+
; CHECK-NEXT: orps %xmm1, %xmm0
328+
; CHECK-NEXT: retq
329+
%conv = bitcast double %a to i64
330+
%and = or i64 %conv, -9223372036854775808
331+
%conv1 = bitcast i64 %and to double
332+
ret double %conv1
333+
}
334+
335+
define <4 x float> @nabsv4f32(<4 x float> %a) {
336+
; CHECK-LABEL: nabsv4f32:
337+
; CHECK: # %bb.0:
338+
; CHECK-NEXT: orps {{.*}}(%rip), %xmm0
339+
; CHECK-NEXT: retq
340+
%conv = bitcast <4 x float> %a to <4 x i32>
341+
%and = or <4 x i32> %conv, <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>
342+
%conv1 = bitcast <4 x i32> %and to <4 x float>
343+
ret <4 x float> %conv1
344+
}
345+
346+
define <2 x double> @nabsv2d64(<2 x double> %a) {
347+
; CHECK-LABEL: nabsv2d64:
348+
; CHECK: # %bb.0:
349+
; CHECK-NEXT: orps {{.*}}(%rip), %xmm0
350+
; CHECK-NEXT: retq
351+
%conv = bitcast <2 x double> %a to <2 x i64>
352+
%and = or <2 x i64> %conv, <i64 -9223372036854775808, i64 -9223372036854775808>
353+
%conv1 = bitcast <2 x i64> %and to <2 x double>
354+
ret <2 x double> %conv1
355+
}
356+
311357
define <4 x float> @fadd_bitcast_fneg_vec(<4 x float> %x, <4 x float> %y) {
312358
; CHECK-LABEL: fadd_bitcast_fneg_vec:
313359
; CHECK: # %bb.0:

0 commit comments

Comments
 (0)
Please sign in to comment.