2017-02-23 02:47:41 +08:00
|
|
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - | FileCheck %s
|
2016-08-24 02:20:09 +08:00
|
|
|
|
|
|
|
--- |
|
|
|
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
2016-10-14 18:19:40 +08:00
|
|
|
target triple = "aarch64--"
|
2016-08-24 02:20:09 +08:00
|
|
|
define void @test_load(i8* %addr) {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
define void @test_store(i8* %addr) {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
...
|
|
|
|
|
|
|
|
---
|
|
|
|
name: test_load
|
|
|
|
registers:
|
|
|
|
- { id: 0, class: _ }
|
|
|
|
- { id: 1, class: _ }
|
|
|
|
- { id: 2, class: _ }
|
|
|
|
- { id: 3, class: _ }
|
|
|
|
- { id: 4, class: _ }
|
|
|
|
- { id: 5, class: _ }
|
2016-09-14 16:28:54 +08:00
|
|
|
- { id: 6, class: _ }
|
2016-10-11 08:21:08 +08:00
|
|
|
- { id: 7, class: _ }
|
2017-01-19 09:05:48 +08:00
|
|
|
- { id: 8, class: _ }
|
2016-08-24 02:20:09 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
2018-02-01 06:04:26 +08:00
|
|
|
liveins: $x0, $x1, $x2, $x3
|
2016-08-24 02:20:09 +08:00
|
|
|
; CHECK-LABEL: name: test_load
|
2018-02-01 06:04:26 +08:00
|
|
|
%0(p0) = COPY $x0
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2016-09-09 19:46:34 +08:00
|
|
|
%1(s1) = G_LOAD %0 :: (load 1 from %ir.addr)
|
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE
Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.
Updated legalization algorithm to roughly the following pseudo code.
WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);
do {
for (Inst in Insts)
legalizeInstrStep(Inst, Insts, Artifacts);
for (Artifact in Artifacts)
tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());
Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.
llvm-svn: 318210
2017-11-15 06:42:19 +08:00
|
|
|
%9:_(s32) = G_ANYEXT %1
|
2018-02-01 06:04:26 +08:00
|
|
|
$w0 = COPY %9
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: %2:_(s8) = G_LOAD %0(p0) :: (load 1 from %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%2(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
|
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE
Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.
Updated legalization algorithm to roughly the following pseudo code.
WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);
do {
for (Inst in Insts)
legalizeInstrStep(Inst, Insts, Artifacts);
for (Artifact in Artifacts)
tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());
Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.
llvm-svn: 318210
2017-11-15 06:42:19 +08:00
|
|
|
%10:_(s32) = G_ANYEXT %2
|
2018-02-01 06:04:26 +08:00
|
|
|
$w0 = COPY %10
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: %3:_(s16) = G_LOAD %0(p0) :: (load 2 from %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%3(s16) = G_LOAD %0 :: (load 2 from %ir.addr)
|
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE
Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.
Updated legalization algorithm to roughly the following pseudo code.
WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);
do {
for (Inst in Insts)
legalizeInstrStep(Inst, Insts, Artifacts);
for (Artifact in Artifacts)
tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());
Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.
llvm-svn: 318210
2017-11-15 06:42:19 +08:00
|
|
|
%11:_(s32) = G_ANYEXT %3
|
2018-02-01 06:04:26 +08:00
|
|
|
$w0 = COPY %11
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: %4:_(s32) = G_LOAD %0(p0) :: (load 4 from %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%4(s32) = G_LOAD %0 :: (load 4 from %ir.addr)
|
2018-02-01 06:04:26 +08:00
|
|
|
$w0 = COPY %4
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: %5:_(s64) = G_LOAD %0(p0) :: (load 8 from %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%5(s64) = G_LOAD %0 :: (load 8 from %ir.addr)
|
2018-02-01 06:04:26 +08:00
|
|
|
$x0 = COPY %5
|
2016-09-14 16:28:54 +08:00
|
|
|
|
|
|
|
%6(p0) = G_LOAD %0(p0) :: (load 8 from %ir.addr)
|
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE
Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.
Updated legalization algorithm to roughly the following pseudo code.
WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);
do {
for (Inst in Insts)
legalizeInstrStep(Inst, Insts, Artifacts);
for (Artifact in Artifacts)
tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());
Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.
llvm-svn: 318210
2017-11-15 06:42:19 +08:00
|
|
|
%12:_(s64) = G_PTRTOINT %6
|
2018-02-01 06:04:26 +08:00
|
|
|
$x0 = COPY %12
|
2016-10-11 08:21:08 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: %7:_(<2 x s32>) = G_LOAD %0(p0) :: (load 8 from %ir.addr)
|
2016-10-11 08:21:08 +08:00
|
|
|
%7(<2 x s32>) = G_LOAD %0(p0) :: (load 8 from %ir.addr)
|
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE
Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.
Updated legalization algorithm to roughly the following pseudo code.
WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);
do {
for (Inst in Insts)
legalizeInstrStep(Inst, Insts, Artifacts);
for (Artifact in Artifacts)
tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());
Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.
llvm-svn: 318210
2017-11-15 06:42:19 +08:00
|
|
|
%13:_(s64) = G_BITCAST %7
|
2018-02-01 06:04:26 +08:00
|
|
|
$x0 = COPY %13
|
2017-01-19 09:05:48 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: [[LOAD0:%[0-9]+]]:_(s64) = G_LOAD %0(p0) :: (load 16 from %ir.addr)
|
|
|
|
; CHECK: [[OFFSET1:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
|
|
|
|
; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP %0, [[OFFSET1]](s64)
|
|
|
|
; CHECK: [[LOAD1:%[0-9]+]]:_(s64) = G_LOAD [[GEP1]](p0) :: (load 16 from %ir.addr)
|
|
|
|
; CHECK: %8:_(s128) = G_MERGE_VALUES [[LOAD0]](s64), [[LOAD1]](s64)
|
2017-01-19 09:05:48 +08:00
|
|
|
%8(s128) = G_LOAD %0(p0) :: (load 16 from %ir.addr)
|
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE
Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.
Updated legalization algorithm to roughly the following pseudo code.
WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);
do {
for (Inst in Insts)
legalizeInstrStep(Inst, Insts, Artifacts);
for (Artifact in Artifacts)
tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());
Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.
llvm-svn: 318210
2017-11-15 06:42:19 +08:00
|
|
|
%14:_(s64) = G_TRUNC %8
|
2018-02-01 06:04:26 +08:00
|
|
|
$x0 = COPY %14
|
2016-08-24 02:20:09 +08:00
|
|
|
...
|
|
|
|
|
|
|
|
---
|
|
|
|
name: test_store
|
|
|
|
registers:
|
|
|
|
- { id: 0, class: _ }
|
|
|
|
- { id: 1, class: _ }
|
|
|
|
- { id: 2, class: _ }
|
|
|
|
- { id: 3, class: _ }
|
|
|
|
- { id: 4, class: _ }
|
2016-09-09 19:46:34 +08:00
|
|
|
- { id: 5, class: _ }
|
2017-01-19 01:29:54 +08:00
|
|
|
- { id: 6, class: _ }
|
|
|
|
- { id: 7, class: _ }
|
2016-08-24 02:20:09 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
2018-02-01 06:04:26 +08:00
|
|
|
liveins: $x0, $x1, $x2, $x3
|
2016-08-24 02:20:09 +08:00
|
|
|
; CHECK-LABEL: name: test_store
|
|
|
|
|
2018-02-01 06:04:26 +08:00
|
|
|
%0(p0) = COPY $x0
|
|
|
|
%1(s32) = COPY $w1
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: [[C1:%.*]]:_(s32) = G_CONSTANT i32 1
|
|
|
|
; CHECK: [[B:%.*]]:_(s32) = COPY %1(s32)
|
|
|
|
; CHECK: [[COPY_C1:%.*]]:_(s32) = COPY [[C1]]
|
|
|
|
; CHECK: [[AND:%.*]]:_(s32) = G_AND [[B]], [[COPY_C1]]
|
|
|
|
; CHECK: [[BIT8:%.*]]:_(s8) = G_TRUNC [[AND]]
|
2017-08-31 03:32:59 +08:00
|
|
|
|
|
|
|
|
2016-09-12 19:20:10 +08:00
|
|
|
; CHECK: G_STORE [[BIT8]](s8), %0(p0) :: (store 1 into %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%2(s1) = G_TRUNC %1
|
|
|
|
G_STORE %2, %0 :: (store 1 into %ir.addr)
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2016-09-12 19:20:10 +08:00
|
|
|
; CHECK: G_STORE %3(s8), %0(p0) :: (store 1 into %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%3(s8) = G_TRUNC %1
|
|
|
|
G_STORE %3, %0 :: (store 1 into %ir.addr)
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2016-09-12 19:20:10 +08:00
|
|
|
; CHECK: G_STORE %4(s16), %0(p0) :: (store 2 into %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
%4(s16) = G_TRUNC %1
|
|
|
|
G_STORE %4, %0 :: (store 2 into %ir.addr)
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2016-09-12 19:20:10 +08:00
|
|
|
; CHECK: G_STORE %1(s32), %0(p0) :: (store 4 into %ir.addr)
|
2016-09-09 19:46:34 +08:00
|
|
|
G_STORE %1, %0 :: (store 4 into %ir.addr)
|
2016-08-24 02:20:09 +08:00
|
|
|
|
2016-09-12 19:20:10 +08:00
|
|
|
; CHECK: G_STORE %5(s64), %0(p0) :: (store 8 into %ir.addr)
|
|
|
|
%5(s64) = G_PTRTOINT %0(p0)
|
2016-09-09 19:46:34 +08:00
|
|
|
G_STORE %5, %0 :: (store 8 into %ir.addr)
|
2016-09-14 16:28:54 +08:00
|
|
|
|
|
|
|
; CHECK: G_STORE %0(p0), %0(p0) :: (store 8 into %ir.addr)
|
|
|
|
G_STORE %0(p0), %0(p0) :: (store 8 into %ir.addr)
|
2017-01-19 01:29:54 +08:00
|
|
|
|
[globalisel][legalizer] G_LOAD/G_STORE NarrowScalar should not emit G_GEP x, 0.
Summary:
When legalizing G_LOAD/G_STORE using NarrowScalar, we should avoid emitting
%0 = G_CONSTANT ty 0
%1 = G_GEP %x, %0
since it's cheaper to not emit the redundant instructions than it is to fold them
away later.
Reviewers: qcolombet, t.p.northover, ab, rovka, aditya_nandakumar, kristof.beyls
Reviewed By: qcolombet
Subscribers: javed.absar, llvm-commits, igorb
Differential Revision: https://reviews.llvm.org/D32746
llvm-svn: 305340
2017-06-14 07:42:32 +08:00
|
|
|
; CHECK: G_STORE %5(s64), %0(p0) :: (store 16 into %ir.addr)
|
2017-10-25 02:04:54 +08:00
|
|
|
; CHECK: [[OFFSET1:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
|
|
|
|
; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP %0, [[OFFSET1]](s64)
|
2017-01-19 01:29:54 +08:00
|
|
|
; CHECK: G_STORE %6(s64), [[GEP1]](p0) :: (store 16 into %ir.addr)
|
|
|
|
%6(s64) = G_PTRTOINT %0(p0)
|
2017-03-04 06:46:09 +08:00
|
|
|
%7(s128) = G_MERGE_VALUES %5, %6
|
2017-01-19 01:29:54 +08:00
|
|
|
G_STORE %7, %0 :: (store 16 into %ir.addr)
|
2016-08-24 02:20:09 +08:00
|
|
|
...
|