-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GlobalISel] Implement some binary reassociations, G_ADD for now
- (op (op X, C1), C2) -> (op X, (op C1, C2)) - (op (op X, C1), Y) -> (op (op X, Y), C1) Some code duplication with the G_PTR_ADD reassociations unfortunately but no easy way to avoid it that I can see. Differential Revision: https://reviews.llvm.org/D150230
- Loading branch information
Showing
11 changed files
with
264 additions
and
39 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
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
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
124 changes: 124 additions & 0 deletions
124
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizer-combiner-binop-reassoc.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,124 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs -mtriple aarch64-unknown-unknown %s -o - | FileCheck %s | ||
|
||
# Combins: (Opc (Opc X, C1), C2) -> (Opc X, (Opc C1, C2)) | ||
--- | ||
name: test1_add_move_inner_cst_to_fold | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
liveins: | ||
- { reg: '$x0' } | ||
body: | | ||
bb.1: | ||
liveins: $x0 | ||
; CHECK-LABEL: name: test1_add_move_inner_cst_to_fold | ||
; CHECK: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: %x:_(s64) = COPY $x0 | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 88 | ||
; CHECK-NEXT: %add_outer:_(s64) = G_ADD %x, [[C]] | ||
; CHECK-NEXT: $x0 = COPY %add_outer(s64) | ||
; CHECK-NEXT: RET_ReallyLR implicit $x0 | ||
%x:_(s64) = COPY $x0 | ||
%C1:_(s64) = G_CONSTANT i64 64 | ||
%C2:_(s64) = G_CONSTANT i64 24 | ||
%add_inner:_(s64) = G_ADD %x, %C1 | ||
%add_outer:_(s64) = G_ADD %add_inner, %C2 | ||
$x0 = COPY %add_outer | ||
RET_ReallyLR implicit $x0 | ||
... | ||
|
||
# (op (op x, c1), y) -> (op (op x, y), c1) | ||
--- | ||
name: test2_add_move_inner_cst_to_rhs | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
liveins: | ||
- { reg: '$x0' } | ||
body: | | ||
bb.1: | ||
liveins: $x0, $x1 | ||
; CHECK-LABEL: name: test2_add_move_inner_cst_to_rhs | ||
; CHECK: liveins: $x0, $x1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: %x:_(s64) = COPY $x0 | ||
; CHECK-NEXT: %C1:_(s64) = G_CONSTANT i64 64 | ||
; CHECK-NEXT: %y:_(s64) = COPY $x1 | ||
; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD %x, %y | ||
; CHECK-NEXT: %add_outer:_(s64) = G_ADD [[ADD]], %C1 | ||
; CHECK-NEXT: $x0 = COPY %add_outer(s64) | ||
; CHECK-NEXT: RET_ReallyLR implicit $x0 | ||
%x:_(s64) = COPY $x0 | ||
%C1:_(s64) = G_CONSTANT i64 64 | ||
%y:_(s64) = COPY $x1 | ||
%add_inner:_(s64) = G_ADD %x, %C1 | ||
%add_outer:_(s64) = G_ADD %add_inner, %y | ||
$x0 = COPY %add_outer | ||
RET_ReallyLR implicit $x0 | ||
... | ||
--- | ||
name: test2_add_move_inner_cst_to_rhs_multiuse | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
liveins: | ||
- { reg: '$x0' } | ||
body: | | ||
bb.1: | ||
liveins: $x0, $x1 | ||
; CHECK-LABEL: name: test2_add_move_inner_cst_to_rhs_multiuse | ||
; CHECK: liveins: $x0, $x1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: %x:_(s64) = COPY $x0 | ||
; CHECK-NEXT: %C1:_(s64) = G_CONSTANT i64 64 | ||
; CHECK-NEXT: %y:_(s64) = COPY $x1 | ||
; CHECK-NEXT: %add_inner:_(s64) = G_ADD %x, %C1 | ||
; CHECK-NEXT: %add_outer:_(s64) = G_ADD %add_inner, %y | ||
; CHECK-NEXT: $x0 = COPY %add_outer(s64) | ||
; CHECK-NEXT: $x1 = COPY %add_inner(s64) | ||
; CHECK-NEXT: RET_ReallyLR implicit $x0 | ||
%x:_(s64) = COPY $x0 | ||
%C1:_(s64) = G_CONSTANT i64 64 | ||
%y:_(s64) = COPY $x1 | ||
%add_inner:_(s64) = G_ADD %x, %C1 | ||
%add_outer:_(s64) = G_ADD %add_inner, %y | ||
$x0 = COPY %add_outer | ||
$x1 = COPY %add_inner | ||
RET_ReallyLR implicit $x0 | ||
... | ||
--- | ||
name: test2_add_move_inner_cst_to_rhs_vector | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
liveins: | ||
- { reg: '$x0' } | ||
body: | | ||
bb.1: | ||
liveins: $q0, $q1 | ||
; CHECK-LABEL: name: test2_add_move_inner_cst_to_rhs_vector | ||
; CHECK: liveins: $q0, $q1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: %x:_(<2 x s64>) = COPY $q0 | ||
; CHECK-NEXT: %C1:_(s64) = G_CONSTANT i64 64 | ||
; CHECK-NEXT: %VEC_C1:_(<2 x s64>) = G_BUILD_VECTOR %C1(s64), %C1(s64) | ||
; CHECK-NEXT: %y:_(<2 x s64>) = COPY $q1 | ||
; CHECK-NEXT: [[ADD:%[0-9]+]]:_(<2 x s64>) = G_ADD %x, %y | ||
; CHECK-NEXT: %add_outer:_(<2 x s64>) = G_ADD [[ADD]], %VEC_C1 | ||
; CHECK-NEXT: $q0 = COPY %add_outer(<2 x s64>) | ||
; CHECK-NEXT: RET_ReallyLR implicit $q0 | ||
%x:_(<2 x s64>) = COPY $q0 | ||
%C1:_(s64) = G_CONSTANT i64 64 | ||
%VEC_C1:_(<2 x s64>) = G_BUILD_VECTOR %C1, %C1 | ||
%y:_(<2 x s64>) = COPY $q1 | ||
%add_inner:_(<2 x s64>) = G_ADD %x, %VEC_C1 | ||
%add_outer:_(<2 x s64>) = G_ADD %add_inner, %y | ||
$q0 = COPY %add_outer | ||
RET_ReallyLR implicit $q0 | ||
... |
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.