Skip to content

Commit 884ff9e

Browse files
committed
[LegalizeVectorOps] Make the AArch64 hack in ExpandFNEG more specific.
Only scalarize single element vectors when vector FSUB is not supported and scalar FNEG is supported.
1 parent 2f7ffba commit 884ff9e

File tree

4 files changed

+560
-1009
lines changed

4 files changed

+560
-1009
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,9 +1793,13 @@ SDValue VectorLegalizer::ExpandFNEG(SDNode *Node) {
17931793
EVT VT = Node->getValueType(0);
17941794
EVT IntVT = VT.changeVectorElementTypeToInteger();
17951795

1796-
// FIXME: The FSUB check is here to force unrolling v1f64 vectors on AArch64.
1797-
if (!TLI.isOperationLegalOrCustom(ISD::XOR, IntVT) ||
1798-
!(TLI.isOperationLegalOrCustom(ISD::FSUB, VT) || VT.isScalableVector()))
1796+
if (!TLI.isOperationLegalOrCustom(ISD::XOR, IntVT))
1797+
return SDValue();
1798+
1799+
// FIXME: This is to force unrolling v1f64 vectors for AArch64.
1800+
if (VT.isFixedLengthVector() && VT.getVectorNumElements() == 1 &&
1801+
!TLI.isOperationLegalOrCustom(ISD::FSUB, VT) &&
1802+
TLI.isOperationLegal(ISD::FNEG, VT.getVectorElementType()))
17991803
return SDValue();
18001804

18011805
SDLoc DL(Node);

llvm/test/CodeGen/NVPTX/f16-instructions.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,8 +1192,7 @@ define half @test_neg_f16(half noundef %arg) #0 {
11921192
; CHECK-LABEL: test_neg_f16x2(
11931193
; CHECK-F16-NOFTZ: neg.f16x2
11941194
; CHECK-F16-FTZ: neg.ftz.f16x2
1195-
; CHECK-NOF16: xor.b16 %rs{{.*}}, %rs{{.*}}, -32768
1196-
; CHECK-NOF16: xor.b16 %rs{{.*}}, %rs{{.*}}, -32768
1195+
; CHECK-NOF16: xor.b32 %r{{.*}}, %r{{.*}}, -2147450880
11971196
define <2 x half> @test_neg_f16x2(<2 x half> noundef %arg) #0 {
11981197
%res = fneg <2 x half> %arg
11991198
ret <2 x half> %res

0 commit comments

Comments
 (0)