-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine VExtract intrinsics into generic opcode in PreLegalizerCombiner
- Loading branch information
1 parent
d07f22b
commit de8468e
Showing
4 changed files
with
290 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
llvm/test/CodeGen/AIE/aie2/GlobalISel/combine-vextract-prelegalizer.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# | ||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# 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 | ||
# RUN: llc -mtriple aie2 -run-pass=aie2-prelegalizer-combiner %s -verify-machineinstrs -o - | FileCheck %s | ||
|
||
--- | ||
name: vextract.8.zext | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.8.zext | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<64 x s8>) = COPY $x0 | ||
; CHECK-NEXT: [[AIE_ZEXT_EXTRACT_VECTOR_ELT:%[0-9]+]]:_(s20) = G_AIE_ZEXT_EXTRACT_VECTOR_ELT [[COPY]](<64 x s8>), [[C]](s32) | ||
; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s20) = G_ASSERT_ZEXT [[AIE_ZEXT_EXTRACT_VECTOR_ELT]], 8 | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[ASSERT_ZEXT]](s20) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = G_CONSTANT i32 0 | ||
%2:_(<64 x s8>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem8.I512), %2(<64 x s8>), %0(s32), %1(s32) | ||
%4:_(s8) = G_TRUNC %3(s32) | ||
%5:_(s20) = G_ZEXT %4(s8) | ||
PseudoRET implicit $lr, implicit %5 | ||
... | ||
|
||
--- | ||
name: vextract.8.sext | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.8.sext | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<64 x s8>) = COPY $x0 | ||
; CHECK-NEXT: [[AIE_SEXT_EXTRACT_VECTOR_ELT:%[0-9]+]]:_(s20) = G_AIE_SEXT_EXTRACT_VECTOR_ELT [[COPY]](<64 x s8>), [[C]](s32) | ||
; CHECK-NEXT: [[ASSERT_SEXT:%[0-9]+]]:_(s20) = G_ASSERT_SEXT [[AIE_SEXT_EXTRACT_VECTOR_ELT]], 8 | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[ASSERT_SEXT]](s20) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = G_CONSTANT i32 1 | ||
%2:_(<64 x s8>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem8.I512), %2(<64 x s8>), %0(s32), %1(s32) | ||
%4:_(s8) = G_TRUNC %3(s32) | ||
%5:_(s20) = G_SEXT %4(s8) | ||
PseudoRET implicit $lr, implicit %5 | ||
... | ||
|
||
# Negative Test Case: Combining is not possible because the vextract8 is used directly without being truncated and extended | ||
--- | ||
name: vextract.8.neg | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.8.neg | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<64 x s8>) = COPY $x0 | ||
; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem8.I512), [[COPY]](<64 x s8>), [[C]](s32), [[C1]](s32) | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[INT]](s32) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = G_CONSTANT i32 1 | ||
%2:_(<64 x s8>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem8.I512), %2(<64 x s8>), %0(s32), %1(s32) | ||
PseudoRET implicit $lr, implicit %3 | ||
... | ||
|
||
# Negative Test Case: Combining is not possible because the vextract8 has a non-constant sign register | ||
--- | ||
name: vextract.8.non.constant.sign | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.8.non.constant.sign | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $r1 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<64 x s8>) = COPY $x0 | ||
; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem8.I512), [[COPY1]](<64 x s8>), [[C]](s32), [[COPY]](s32) | ||
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[INT]](s32) | ||
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s20) = G_SEXT [[TRUNC]](s8) | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[SEXT]](s20) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = COPY $r1 | ||
%2:_(<64 x s8>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem8.I512), %2(<64 x s8>), %0(s32), %1(s32) | ||
%4:_(s8) = G_TRUNC %3(s32) | ||
%5:_(s20) = G_SEXT %4(s8) | ||
PseudoRET implicit $lr, implicit %5 | ||
... | ||
|
||
--- | ||
name: vextract.16.zext | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.16.zext | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<32 x s16>) = COPY $x0 | ||
; CHECK-NEXT: [[AIE_ZEXT_EXTRACT_VECTOR_ELT:%[0-9]+]]:_(s20) = G_AIE_ZEXT_EXTRACT_VECTOR_ELT [[COPY]](<32 x s16>), [[C]](s32) | ||
; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s20) = G_ASSERT_ZEXT [[AIE_ZEXT_EXTRACT_VECTOR_ELT]], 16 | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[ASSERT_ZEXT]](s20) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = G_CONSTANT i32 0 | ||
%2:_(<32 x s16>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem16.I512), %2(<32 x s16>), %0(s32), %1(s32) | ||
%4:_(s16) = G_TRUNC %3(s32) | ||
%5:_(s20) = G_ZEXT %4(s16) | ||
PseudoRET implicit $lr, implicit %5 | ||
... | ||
|
||
--- | ||
name: vextract.16.sext | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.16.sext | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<32 x s16>) = COPY $x0 | ||
; CHECK-NEXT: [[AIE_SEXT_EXTRACT_VECTOR_ELT:%[0-9]+]]:_(s20) = G_AIE_SEXT_EXTRACT_VECTOR_ELT [[COPY]](<32 x s16>), [[C]](s32) | ||
; CHECK-NEXT: [[ASSERT_SEXT:%[0-9]+]]:_(s20) = G_ASSERT_SEXT [[AIE_SEXT_EXTRACT_VECTOR_ELT]], 16 | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[ASSERT_SEXT]](s20) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = G_CONSTANT i32 1 | ||
%2:_(<32 x s16>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem16.I512), %2(<32 x s16>), %0(s32), %1(s32) | ||
%4:_(s16) = G_TRUNC %3(s32) | ||
%5:_(s20) = G_SEXT %4(s16) | ||
PseudoRET implicit $lr, implicit %5 | ||
... | ||
|
||
# Negative Test Case: Combining is not possible because the vextract16 is used directly without being truncated and extended | ||
--- | ||
name: vextract.16.neg | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.16.neg | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<32 x s16>) = COPY $x0 | ||
; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem16.I512), [[COPY]](<32 x s16>), [[C]](s32), [[C1]](s32) | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[INT]](s32) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = G_CONSTANT i32 1 | ||
%2:_(<32 x s16>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem16.I512), %2(<32 x s16>), %0(s32), %1(s32) | ||
PseudoRET implicit $lr, implicit %3 | ||
... | ||
|
||
# Negative Test Case: Combining is not possible because the vextract16 has a non-constant sign register | ||
--- | ||
name: vextract.16.non.constant.sign | ||
legalized: false | ||
body: | | ||
bb.1.entry: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: vextract.16.non.constant.sign | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 7 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $r1 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<32 x s16>) = COPY $x0 | ||
; CHECK-NEXT: [[INT:%[0-9]+]]:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem16.I512), [[COPY1]](<32 x s16>), [[C]](s32), [[COPY]](s32) | ||
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[INT]](s32) | ||
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s20) = G_SEXT [[TRUNC]](s16) | ||
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[SEXT]](s20) | ||
%0:_(s32) = G_CONSTANT i32 7 | ||
%1:_(s32) = COPY $r1 | ||
%2:_(<32 x s16>) = COPY $x0 | ||
%3:_(s32) = G_INTRINSIC intrinsic(@llvm.aie2.vextract.elem16.I512), %2(<32 x s16>), %0(s32), %1(s32) | ||
%4:_(s16) = G_TRUNC %3(s32) | ||
%5:_(s20) = G_SEXT %4(s16) | ||
PseudoRET implicit $lr, implicit %5 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters