summaryrefslogtreecommitdiffhomepage
path: root/ir/be/riscv
diff options
context:
space:
mode:
authorJohannes Bucher <johannes.bucher2@student.kit.edu>2019-05-17 14:45:59 +0200
committerJohannes Bucher <johannes.bucher2@student.kit.edu>2019-05-17 14:45:59 +0200
commit5d8d3b233eb47bf1c317c7c822983d5524535653 (patch)
tree021cfb02cd572d7cfde4e2c07fd70535c96f124f /ir/be/riscv
parent0b22246bd37ea4d4fb772caf659fa7d449571e3a (diff)
riscv: do not emit IncSP nodes with offset 0
Diffstat (limited to 'ir/be/riscv')
-rw-r--r--ir/be/riscv/riscv_emitter.c3
-rw-r--r--ir/be/riscv/riscv_finish.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/ir/be/riscv/riscv_emitter.c b/ir/be/riscv/riscv_emitter.c
index fc89483..2059fc1 100644
--- a/ir/be/riscv/riscv_emitter.c
+++ b/ir/be/riscv/riscv_emitter.c
@@ -188,6 +188,9 @@ static void emit_be_Copy(ir_node const *const node)
static void emit_be_IncSP(ir_node const *const node)
{
int const offs = -be_get_IncSP_offset(node);
+ if (offs == 0) {
+ return;
+ }
assert(is_simm12(offs));
riscv_emitf(node, "addi\t%D0, %S0, %d", offs);
}
diff --git a/ir/be/riscv/riscv_finish.c b/ir/be/riscv/riscv_finish.c
index e434878..81a7b39 100644
--- a/ir/be/riscv/riscv_finish.c
+++ b/ir/be/riscv/riscv_finish.c
@@ -117,11 +117,16 @@ static void finish_be_IncSP(ir_node *node)
}
}
+static void peephole_be_IncSP(ir_node *const node)
+{
+ be_peephole_IncSP_IncSP(node);
+}
+
void riscv_finish_graph(ir_graph *irg)
{
/* perform peephole optimizations */
ir_clear_opcodes_generic_func();
-
+ register_peephole_optimization(op_be_IncSP, peephole_be_IncSP);
be_peephole_opt(irg);
/* perform legalizations (mostly fix nodes with too big immediates) */