-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine (shl (and x, 2^n-1), n) to (shl x, n)
- Loading branch information
1 parent
ef131e8
commit f6001f9
Showing
33 changed files
with
1,160 additions
and
1,344 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
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
152 changes: 152 additions & 0 deletions
152
llvm/test/CodeGen/AArch64/GlobalISel/combine-shl-and.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,152 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# | ||
# Part of the LLVM Project, 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 | ||
# | ||
# Modifications (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates | ||
# RUN: llc -mtriple aarch64 -run-pass=aarch64-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | ||
name: test_combine_shl_of_and_I16_shift_8 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $w0 | ||
; CHECK-LABEL: name: test_combine_shl_of_and_I16_shift_8 | ||
; CHECK: liveins: $w0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 8 | ||
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32) | ||
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s16) = G_SHL [[TRUNC]], [[C]](s16) | ||
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[SHL]](s16) | ||
; CHECK-NEXT: $w0 = COPY [[SEXT]](s32) | ||
%0:_(s32) = COPY $w0 | ||
%1:_(s16) = G_CONSTANT i16 8 | ||
%2:_(s16) = G_CONSTANT i16 255 | ||
%3:_(s16) = G_TRUNC %0 | ||
%4:_(s16) = G_AND %3, %2 | ||
%5:_(s16) = G_SHL %4, %1 | ||
%6:_(s32) = G_SEXT %5 | ||
$w0 = COPY %6(s32) | ||
... | ||
--- | ||
# Negative test case: Here we're trying to shift less than half size. | ||
name: test_combine_shl_of_and_I16_shift_4_neg | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $w0 | ||
; CHECK-LABEL: name: test_combine_shl_of_and_I16_shift_4_neg | ||
; CHECK: liveins: $w0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 4 | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s16) = G_CONSTANT i16 15 | ||
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32) | ||
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s16) = G_AND [[TRUNC]], [[C1]] | ||
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s16) = G_SHL [[AND]], [[C]](s16) | ||
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[SHL]](s16) | ||
; CHECK-NEXT: $w0 = COPY [[SEXT]](s32) | ||
%0:_(s32) = COPY $w0 | ||
%1:_(s16) = G_CONSTANT i16 4 | ||
%2:_(s16) = G_CONSTANT i16 15 | ||
%3:_(s16) = G_TRUNC %0 | ||
%4:_(s16) = G_AND %3, %2 | ||
%5:_(s16) = G_SHL %4, %1 | ||
%6:_(s32) = G_SEXT %5 | ||
$w0 = COPY %6(s32) | ||
... | ||
--- | ||
name: test_combine_shl_of_and_I32_shift_16 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $w0 | ||
; CHECK-LABEL: name: test_combine_shl_of_and_I32_shift_16 | ||
; CHECK: liveins: $w0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 | ||
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32) | ||
; CHECK-NEXT: $w0 = COPY [[SHL]](s32) | ||
%0:_(s32) = COPY $w0 | ||
%1:_(s32) = G_CONSTANT i32 16 | ||
%2:_(s32) = G_CONSTANT i32 65535 | ||
%3:_(s32) = G_AND %0, %2 | ||
%4:_(s32) = G_SHL %3, %1 | ||
$w0 = COPY %4(s32) | ||
... | ||
--- | ||
name: test_combine_shl_of_and_I32_shift_24 | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $w0 | ||
; CHECK-LABEL: name: test_combine_shl_of_and_I32_shift_24 | ||
; CHECK: liveins: $w0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 | ||
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32) | ||
; CHECK-NEXT: $w0 = COPY [[SHL]](s32) | ||
%0:_(s32) = COPY $w0 | ||
%1:_(s32) = G_CONSTANT i32 24 | ||
%2:_(s32) = G_CONSTANT i32 16777215 | ||
%3:_(s32) = G_AND %0, %2 | ||
%4:_(s32) = G_SHL %3, %1 | ||
$w0 = COPY %4(s32) | ||
... | ||
--- | ||
# Negative test case: Here we're trying to shift less than half size. | ||
name: test_combine_shl_of_and_I32_shift_8_neg | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $w0 | ||
; CHECK-LABEL: name: test_combine_shl_of_and_I32_shift_8_neg | ||
; CHECK: liveins: $w0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 8 | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 | ||
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C1]] | ||
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND]], [[C]](s32) | ||
; CHECK-NEXT: $w0 = COPY [[SHL]](s32) | ||
%0:_(s32) = COPY $w0 | ||
%1:_(s32) = G_CONSTANT i32 8 | ||
%2:_(s32) = G_CONSTANT i32 255 | ||
%3:_(s32) = G_AND %0, %2 | ||
%4:_(s32) = G_SHL %3, %1 | ||
$w0 = COPY %4(s32) | ||
... | ||
--- | ||
# Negative test case: Here mask 255 is not of shift value i.e. 16 bits. | ||
name: test_combine_shl_of_and_I32_shift_16_neg | ||
legalized: true | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0.entry: | ||
liveins: $w0 | ||
; CHECK-LABEL: name: test_combine_shl_of_and_I32_shift_16_neg | ||
; CHECK: liveins: $w0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 | ||
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C1]] | ||
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND]], [[C]](s32) | ||
; CHECK-NEXT: $w0 = COPY [[SHL]](s32) | ||
%0:_(s32) = COPY $w0 | ||
%1:_(s32) = G_CONSTANT i32 16 | ||
%2:_(s32) = G_CONSTANT i32 255 | ||
%3:_(s32) = G_AND %0, %2 | ||
%4:_(s32) = G_SHL %3, %1 | ||
$w0 = COPY %4(s32) | ||
... |
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
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
Oops, something went wrong.