-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIE] Legalize G_AND for <8 x s64> vector. #262
base: aie-public
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates | ||
// (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
|
@@ -36,36 +36,8 @@ def frameindex_to_targetframeindex : SDNodeXForm<frameindex, [{ | |
def gi_frameindex_to_targetframeindex : GICustomOperandRenderer<"renderFrameIndex">, | ||
GISDNodeXFormEquiv<frameindex_to_targetframeindex>; | ||
|
||
// VBOR / VBAND | ||
foreach vec256Ty = [v32i8, v16i16, v8i32] in { | ||
def : Pat<(vec256Ty (or VEC256:$src1, VEC256:$src2)), | ||
(vec256Ty (EXTRACT_SUBREG (VBOR | ||
(v32i16 (REG_SEQUENCE VEC512, VEC256:$src1, sub_256_lo)), | ||
(v32i16 (REG_SEQUENCE VEC512, VEC256:$src2, sub_256_lo))), | ||
sub_256_lo))>; | ||
def : Pat<(vec256Ty (and VEC256:$src1, VEC256:$src2)), | ||
(vec256Ty (EXTRACT_SUBREG (VBAND | ||
(v32i16 (REG_SEQUENCE VEC512, VEC256:$src1, sub_256_lo)), | ||
(v32i16 (REG_SEQUENCE VEC512, VEC256:$src2, sub_256_lo))), | ||
sub_256_lo))>; | ||
} | ||
// VBOR / VBAND / XOR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we don't have xor here |
||
foreach vec512Ty = [v64i8, v32i16, v16i32] in { | ||
def : Pat<(vec512Ty (or VEC512:$src1, VEC512:$src2)), (VBOR VEC512:$src1, VEC512:$src2)>; | ||
def : Pat<(vec512Ty (and VEC512:$src1, VEC512:$src2)), (VBAND VEC512:$src1, VEC512:$src2)>; | ||
} | ||
foreach vec1024Ty = [v128i8, v64i16, v32i32] in { | ||
def : Pat<(vec1024Ty (or VEC1024:$src1, VEC1024:$src2)), | ||
(REG_SEQUENCE VEC1024, | ||
(VBOR (v16i32 (EXTRACT_SUBREG VEC1024:$src1, sub_512_lo)), | ||
(v16i32 (EXTRACT_SUBREG VEC1024:$src2, sub_512_lo))), sub_512_lo, | ||
(VBOR (v16i32 (EXTRACT_SUBREG VEC1024:$src1, sub_512_hi)), | ||
(v16i32 (EXTRACT_SUBREG VEC1024:$src2, sub_512_hi))), sub_512_hi | ||
)>; | ||
def : Pat<(vec1024Ty (and VEC1024:$src1, VEC1024:$src2)), | ||
(REG_SEQUENCE VEC1024, | ||
(VBAND (v16i32 (EXTRACT_SUBREG VEC1024:$src1, sub_512_lo)), | ||
(v16i32 (EXTRACT_SUBREG VEC1024:$src2, sub_512_lo))), sub_512_lo, | ||
(VBAND (v16i32 (EXTRACT_SUBREG VEC1024:$src1, sub_512_hi)), | ||
(v16i32 (EXTRACT_SUBREG VEC1024:$src2, sub_512_hi))), sub_512_hi | ||
)>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates | ||
// (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// \file | ||
|
@@ -252,12 +252,6 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST) | |
.clampScalar(0, S32, S32); | ||
// FIXME: (s|z|any)ext s20 to s64 is broken. | ||
|
||
getActionDefinitionsBuilder({G_AND, G_OR}) | ||
.legalFor({S32}) | ||
.legalFor(AIE2PVectorTypes) | ||
.widenScalarToNextPow2(0) | ||
.clampScalar(0, S32, S32); | ||
|
||
getActionDefinitionsBuilder(G_SEXT_INREG).custom(); | ||
|
||
getActionDefinitionsBuilder({G_ASHR, G_LSHR, G_SHL}) | ||
|
@@ -305,7 +299,7 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST) | |
.legalFor({V16S32, V32S16, V64S8}) | ||
.widenScalarToNextPow2(0) | ||
.clampScalar(0, S32, S32) | ||
// AIE ISA supports only 512-bit vector add/sub/xor | ||
// AIE ISA supports only 512-bit vector add/sub/xor/and/or | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why do we need to update the comment with "and/or"? |
||
.clampMaxNumElements(0, S8, 64) | ||
.clampMaxNumElements(0, S16, 32) | ||
.clampMaxNumElements(0, S32, 16) | ||
|
@@ -314,6 +308,22 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST) | |
// more optimally. | ||
.customIf(vectorSmallerThan(0, 512)); | ||
|
||
getActionDefinitionsBuilder({G_AND, G_OR}) | ||
.legalFor({S32}) | ||
.legalFor({V16S32, V32S16, V64S8}) | ||
.widenScalarToNextPow2(0) | ||
.clampScalar(0, S32, S32) | ||
// AIE ISA supports only 512-bit vector and/or | ||
.clampMaxNumElements(0, S8, 64) | ||
.clampMaxNumElements(0, S16, 32) | ||
.clampMaxNumElements(0, S32, 16) | ||
// moreElements action could have used here, but it generate code more | ||
// like scalarization. We can use G_CONCAT_VECTORS and unmerge to do this | ||
// more optimally. | ||
.customIf(vectorSmallerThan(0, 512)) | ||
.bitcastIf(typeInSet(0, {AccV4S64, AccV8S64, AccV16S64}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it not for all aie2p accumulator types defined in |
||
bitcastAccToVectorType(0)); | ||
|
||
// FIXME: G_SADDE/G_SSUBE doesn't support lowering. To support this properly, | ||
// the action needs to be implemented | ||
// FIXME: AIE2 has ADC and SBC operations to read the carry. | ||
|
@@ -668,6 +678,8 @@ bool AIE2PLegalizerInfo::legalizeCustom( | |
case TargetOpcode::G_ADD: | ||
case TargetOpcode::G_SUB: | ||
case TargetOpcode::G_XOR: | ||
case TargetOpcode::G_AND: | ||
case TargetOpcode::G_OR: | ||
return AIEHelper.legalizeBinOp(Helper, MI); | ||
} | ||
llvm_unreachable("Un-expected custom legalization"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be shared between aie2 and aie2p? I see we have exactly the same implementation for aie2p.