Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIPS GlobalISel] Select phi instruction for integers
Select G_PHI for integers for MIPS32. Differential Revision: https://reviews.llvm.org/D58183 llvm-svn: 354025
- Loading branch information
Petar Avramovic
authored and
Petar Avramovic
committed
Feb 14, 2019
1 parent
c6e768f
commit 14c7ecf
Showing
6 changed files
with
602 additions
and
0 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
71 changes: 71 additions & 0 deletions
71
llvm/test/CodeGen/Mips/GlobalISel/instruction-select/phi.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,71 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32 | ||
--- | | ||
|
||
define i32 @test_i32(i1 %cnd, i32 %a, i32 %b) { | ||
entry: | ||
br i1 %cnd, label %cond.true, label %cond.false | ||
|
||
cond.true: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.false: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.end: ; preds = %cond.false, %cond.true | ||
%cond = phi i32 [ %a, %cond.true ], [ %b, %cond.false ] | ||
ret i32 %cond | ||
} | ||
|
||
... | ||
--- | ||
name: test_i32 | ||
alignment: 2 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
body: | | ||
; MIPS32-LABEL: name: test_i32 | ||
; MIPS32: bb.0.entry: | ||
; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; MIPS32: liveins: $a0, $a1, $a2 | ||
; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0 | ||
; MIPS32: [[COPY1:%[0-9]+]]:gpr32 = COPY $a1 | ||
; MIPS32: [[COPY2:%[0-9]+]]:gpr32 = COPY $a2 | ||
; MIPS32: [[LUi:%[0-9]+]]:gpr32 = LUi 0 | ||
; MIPS32: [[ORi:%[0-9]+]]:gpr32 = ORi [[LUi]], 1 | ||
; MIPS32: [[AND:%[0-9]+]]:gpr32 = AND [[COPY]], [[ORi]] | ||
; MIPS32: BNE [[AND]], $zero, %bb.1, implicit-def $at | ||
; MIPS32: J %bb.2, implicit-def $at | ||
; MIPS32: bb.1.cond.true: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: J %bb.3, implicit-def $at | ||
; MIPS32: bb.2.cond.false: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: bb.3.cond.end: | ||
; MIPS32: [[PHI:%[0-9]+]]:gpr32 = PHI [[COPY1]], %bb.1, [[COPY2]], %bb.2 | ||
; MIPS32: $v0 = COPY [[PHI]] | ||
; MIPS32: RetRA implicit $v0 | ||
bb.1.entry: | ||
liveins: $a0, $a1, $a2 | ||
%3:gprb(s32) = COPY $a0 | ||
%1:gprb(s32) = COPY $a1 | ||
%2:gprb(s32) = COPY $a2 | ||
%6:gprb(s32) = G_CONSTANT i32 1 | ||
%7:gprb(s32) = COPY %3(s32) | ||
%5:gprb(s32) = G_AND %7, %6 | ||
G_BRCOND %5(s32), %bb.2 | ||
G_BR %bb.3 | ||
bb.2.cond.true: | ||
G_BR %bb.4 | ||
bb.3.cond.false: | ||
bb.4.cond.end: | ||
%4:gprb(s32) = G_PHI %1(s32), %bb.2, %2(s32), %bb.3 | ||
$v0 = COPY %4(s32) | ||
RetRA implicit $v0 | ||
... |
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,271 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32 | ||
--- | | ||
|
||
define i1 @test_i1(i1 %cnd, i1 %a, i1 %b) { | ||
entry: | ||
br i1 %cnd, label %cond.true, label %cond.false | ||
|
||
cond.true: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.false: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.end: ; preds = %cond.false, %cond.true | ||
%cond = phi i1 [ %a, %cond.true ], [ %b, %cond.false ] | ||
ret i1 %cond | ||
} | ||
|
||
define i8 @test_i8(i1 %cnd, i8 %a, i8 %b) { | ||
entry: | ||
br i1 %cnd, label %cond.true, label %cond.false | ||
|
||
cond.true: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.false: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.end: ; preds = %cond.false, %cond.true | ||
%cond = phi i8 [ %a, %cond.true ], [ %b, %cond.false ] | ||
ret i8 %cond | ||
} | ||
|
||
define i16 @test_i16(i1 %cnd, i16 %a, i16 %b) { | ||
entry: | ||
br i1 %cnd, label %cond.true, label %cond.false | ||
|
||
cond.true: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.false: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.end: ; preds = %cond.false, %cond.true | ||
%cond = phi i16 [ %a, %cond.true ], [ %b, %cond.false ] | ||
ret i16 %cond | ||
} | ||
|
||
define i32 @test_i32(i1 %cnd, i32 %a, i32 %b) { | ||
entry: | ||
br i1 %cnd, label %cond.true, label %cond.false | ||
|
||
cond.true: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.false: ; preds = %entry | ||
br label %cond.end | ||
|
||
cond.end: ; preds = %cond.false, %cond.true | ||
%cond = phi i32 [ %a, %cond.true ], [ %b, %cond.false ] | ||
ret i32 %cond | ||
} | ||
|
||
... | ||
--- | ||
name: test_i1 | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
body: | | ||
; MIPS32-LABEL: name: test_i1 | ||
; MIPS32: bb.0.entry: | ||
; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; MIPS32: liveins: $a0, $a1, $a2 | ||
; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 | ||
; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 | ||
; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2 | ||
; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 | ||
; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) | ||
; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] | ||
; MIPS32: G_BRCOND [[AND]](s32), %bb.1 | ||
; MIPS32: G_BR %bb.2 | ||
; MIPS32: bb.1.cond.true: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) | ||
; MIPS32: G_BR %bb.3 | ||
; MIPS32: bb.2.cond.false: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[COPY2]](s32) | ||
; MIPS32: bb.3.cond.end: | ||
; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY4]](s32), %bb.1, [[COPY5]](s32), %bb.2 | ||
; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[PHI]](s32) | ||
; MIPS32: $v0 = COPY [[COPY6]](s32) | ||
; MIPS32: RetRA implicit $v0 | ||
bb.1.entry: | ||
liveins: $a0, $a1, $a2 | ||
%3:_(s32) = COPY $a0 | ||
%0:_(s1) = G_TRUNC %3(s32) | ||
%4:_(s32) = COPY $a1 | ||
%1:_(s1) = G_TRUNC %4(s32) | ||
%5:_(s32) = COPY $a2 | ||
%2:_(s1) = G_TRUNC %5(s32) | ||
G_BRCOND %0(s1), %bb.2 | ||
G_BR %bb.3 | ||
bb.2.cond.true: | ||
G_BR %bb.4 | ||
bb.3.cond.false: | ||
bb.4.cond.end: | ||
%6:_(s1) = G_PHI %1(s1), %bb.2, %2(s1), %bb.3 | ||
%7:_(s32) = G_ANYEXT %6(s1) | ||
$v0 = COPY %7(s32) | ||
RetRA implicit $v0 | ||
... | ||
--- | ||
name: test_i8 | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
body: | | ||
; MIPS32-LABEL: name: test_i8 | ||
; MIPS32: bb.0.entry: | ||
; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; MIPS32: liveins: $a0, $a1, $a2 | ||
; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 | ||
; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 | ||
; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2 | ||
; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 | ||
; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) | ||
; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] | ||
; MIPS32: G_BRCOND [[AND]](s32), %bb.1 | ||
; MIPS32: G_BR %bb.2 | ||
; MIPS32: bb.1.cond.true: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) | ||
; MIPS32: G_BR %bb.3 | ||
; MIPS32: bb.2.cond.false: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[COPY2]](s32) | ||
; MIPS32: bb.3.cond.end: | ||
; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY4]](s32), %bb.1, [[COPY5]](s32), %bb.2 | ||
; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[PHI]](s32) | ||
; MIPS32: $v0 = COPY [[COPY6]](s32) | ||
; MIPS32: RetRA implicit $v0 | ||
bb.1.entry: | ||
liveins: $a0, $a1, $a2 | ||
%3:_(s32) = COPY $a0 | ||
%0:_(s1) = G_TRUNC %3(s32) | ||
%4:_(s32) = COPY $a1 | ||
%1:_(s8) = G_TRUNC %4(s32) | ||
%5:_(s32) = COPY $a2 | ||
%2:_(s8) = G_TRUNC %5(s32) | ||
G_BRCOND %0(s1), %bb.2 | ||
G_BR %bb.3 | ||
bb.2.cond.true: | ||
G_BR %bb.4 | ||
bb.3.cond.false: | ||
bb.4.cond.end: | ||
%6:_(s8) = G_PHI %1(s8), %bb.2, %2(s8), %bb.3 | ||
%7:_(s32) = G_ANYEXT %6(s8) | ||
$v0 = COPY %7(s32) | ||
RetRA implicit $v0 | ||
... | ||
--- | ||
name: test_i16 | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
body: | | ||
; MIPS32-LABEL: name: test_i16 | ||
; MIPS32: bb.0.entry: | ||
; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; MIPS32: liveins: $a0, $a1, $a2 | ||
; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 | ||
; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 | ||
; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2 | ||
; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 | ||
; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) | ||
; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] | ||
; MIPS32: G_BRCOND [[AND]](s32), %bb.1 | ||
; MIPS32: G_BR %bb.2 | ||
; MIPS32: bb.1.cond.true: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) | ||
; MIPS32: G_BR %bb.3 | ||
; MIPS32: bb.2.cond.false: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[COPY2]](s32) | ||
; MIPS32: bb.3.cond.end: | ||
; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY4]](s32), %bb.1, [[COPY5]](s32), %bb.2 | ||
; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[PHI]](s32) | ||
; MIPS32: $v0 = COPY [[COPY6]](s32) | ||
; MIPS32: RetRA implicit $v0 | ||
bb.1.entry: | ||
liveins: $a0, $a1, $a2 | ||
%3:_(s32) = COPY $a0 | ||
%0:_(s1) = G_TRUNC %3(s32) | ||
%4:_(s32) = COPY $a1 | ||
%1:_(s16) = G_TRUNC %4(s32) | ||
%5:_(s32) = COPY $a2 | ||
%2:_(s16) = G_TRUNC %5(s32) | ||
G_BRCOND %0(s1), %bb.2 | ||
G_BR %bb.3 | ||
bb.2.cond.true: | ||
G_BR %bb.4 | ||
bb.3.cond.false: | ||
bb.4.cond.end: | ||
%6:_(s16) = G_PHI %1(s16), %bb.2, %2(s16), %bb.3 | ||
%7:_(s32) = G_ANYEXT %6(s16) | ||
$v0 = COPY %7(s32) | ||
RetRA implicit $v0 | ||
... | ||
--- | ||
name: test_i32 | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
body: | | ||
; MIPS32-LABEL: name: test_i32 | ||
; MIPS32: bb.0.entry: | ||
; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; MIPS32: liveins: $a0, $a1, $a2 | ||
; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 | ||
; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 | ||
; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2 | ||
; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 | ||
; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) | ||
; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] | ||
; MIPS32: G_BRCOND [[AND]](s32), %bb.1 | ||
; MIPS32: G_BR %bb.2 | ||
; MIPS32: bb.1.cond.true: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: G_BR %bb.3 | ||
; MIPS32: bb.2.cond.false: | ||
; MIPS32: successors: %bb.3(0x80000000) | ||
; MIPS32: bb.3.cond.end: | ||
; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2 | ||
; MIPS32: $v0 = COPY [[PHI]](s32) | ||
; MIPS32: RetRA implicit $v0 | ||
bb.1.entry: | ||
liveins: $a0, $a1, $a2 | ||
%3:_(s32) = COPY $a0 | ||
%0:_(s1) = G_TRUNC %3(s32) | ||
%1:_(s32) = COPY $a1 | ||
%2:_(s32) = COPY $a2 | ||
G_BRCOND %0(s1), %bb.2 | ||
G_BR %bb.3 | ||
bb.2.cond.true: | ||
G_BR %bb.4 | ||
bb.3.cond.false: | ||
bb.4.cond.end: | ||
%4:_(s32) = G_PHI %1(s32), %bb.2, %2(s32), %bb.3 | ||
$v0 = COPY %4(s32) | ||
RetRA implicit $v0 | ||
... |
Oops, something went wrong.