We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 827f8a7 commit cdc3732Copy full SHA for cdc3732
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -270,6 +270,7 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
270
setOperationAction({ISD::FMUL, ISD::FDIV}, VT, Legal);
271
setOperationAction(ISD::FMA, VT, Legal);
272
setOperationAction(ISD::FSQRT, VT, Legal);
273
+ setOperationAction(ISD::FNEG, VT, Legal);
274
setCondCodeAction({ISD::SETGE, ISD::SETGT, ISD::SETOGE, ISD::SETOGT,
275
ISD::SETUGE, ISD::SETUGT},
276
VT, Expand);
@@ -311,6 +312,7 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
311
312
313
314
315
316
317
318
llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
@@ -1605,6 +1605,10 @@ foreach vt = [v32i8, v16i16, v8i32, v4i64, v8f32, v4f64] in
1605
def : Pat<(vt (vselect LASX256:$xa, LASX256:$xk, LASX256:$xj)),
1606
(XVBITSEL_V LASX256:$xj, LASX256:$xk, LASX256:$xa)>;
1607
1608
+// fneg
1609
+def : Pat<(fneg (v8f32 LASX256:$xj)), (XVBITREVI_W LASX256:$xj, 31)>;
1610
+def : Pat<(fneg (v4f64 LASX256:$xj)), (XVBITREVI_D LASX256:$xj, 63)>;
1611
+
1612
} // Predicates = [HasExtLASX]
1613
1614
/// Intrinsic pattern
llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
@@ -1712,6 +1712,10 @@ foreach vt = [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64] in
1712
def : Pat<(vt (vselect LSX128:$va, LSX128:$vk, LSX128:$vj)),
1713
(VBITSEL_V LSX128:$vj, LSX128:$vk, LSX128:$va)>;
1714
1715
1716
+def : Pat<(fneg (v4f32 LSX128:$vj)), (VBITREVI_W LSX128:$vj, 31)>;
1717
+def : Pat<(fneg (v2f64 LSX128:$vj)), (VBITREVI_D LSX128:$vj, 63)>;
1718
1719
} // Predicates = [HasExtLSX]
1720
1721
llvm/test/CodeGen/LoongArch/lasx/ir-instruction/fneg.ll
@@ -0,0 +1,29 @@
1
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2
+; RUN: llc --mtriple=loongarch64 --mattr=+lasx < %s | FileCheck %s
3
4
+define void @fneg_v8f32(ptr %res, ptr %a0) nounwind {
5
+; CHECK-LABEL: fneg_v8f32:
6
+; CHECK: # %bb.0: # %entry
7
+; CHECK-NEXT: xvld $xr0, $a1, 0
8
+; CHECK-NEXT: xvbitrevi.w $xr0, $xr0, 31
9
+; CHECK-NEXT: xvst $xr0, $a0, 0
10
+; CHECK-NEXT: ret
11
+entry:
12
+ %v0 = load <8 x float>, ptr %a0
13
+ %v1 = fneg <8 x float> %v0
14
+ store <8 x float> %v1, ptr %res
15
+ ret void
16
+}
17
+define void @fneg_v4f64(ptr %res, ptr %a0) nounwind {
18
+; CHECK-LABEL: fneg_v4f64:
19
20
21
+; CHECK-NEXT: xvbitrevi.d $xr0, $xr0, 63
22
23
24
25
+ %v0 = load <4 x double>, ptr %a0
26
+ %v1 = fneg <4 x double> %v0
27
+ store <4 x double> %v1, ptr %res
28
29
llvm/test/CodeGen/LoongArch/lsx/ir-instruction/fneg.ll
+; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s
+define void @fneg_v4f32(ptr %res, ptr %a0) nounwind {
+; CHECK-LABEL: fneg_v4f32:
+; CHECK-NEXT: vld $vr0, $a1, 0
+; CHECK-NEXT: vbitrevi.w $vr0, $vr0, 31
+; CHECK-NEXT: vst $vr0, $a0, 0
+ %v0 = load <4 x float>, ptr %a0
+ %v1 = fneg <4 x float> %v0
+ store <4 x float> %v1, ptr %res
+define void @fneg_v2f64(ptr %res, ptr %a0) nounwind {
+; CHECK-LABEL: fneg_v2f64:
+; CHECK-NEXT: vbitrevi.d $vr0, $vr0, 63
+ %v0 = load <2 x double>, ptr %a0
+ %v1 = fneg <2 x double> %v0
+ store <2 x double> %v1, ptr %res
0 commit comments