[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 08/10] tcg/optimize: prefer the "op a, a, b" form
From: |
Aurelien Jarno |
Subject: |
[Qemu-devel] [PATCH v2 08/10] tcg/optimize: prefer the "op a, a, b" form for commutative ops |
Date: |
Fri, 21 Sep 2012 21:43:16 +0200 |
The "op a, a, b" form is better handled on non-RISC host than the "op
a, b, a" form, so swap the arguments to this form when possible, and
when b is not a constant.
This reduces the number of generated instructions by a tiny bit.
Signed-off-by: Aurelien Jarno <address@hidden>
---
tcg/optimize.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index abe016a..c8ae50b 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -434,7 +434,10 @@ static TCGArg *tcg_constant_folding(TCGContext *s,
uint16_t *tcg_opc_ptr,
CASE_OP_32_64(eqv):
CASE_OP_32_64(nand):
CASE_OP_32_64(nor):
- if (temps[args[1]].state == TCG_TEMP_CONST) {
+ /* Prefer the constant in second argument, and then the form
+ op a, a, b, which is better handled on non-RISC hosts. */
+ if (temps[args[1]].state == TCG_TEMP_CONST || (args[0] == args[2]
+ && temps[args[2]].state != TCG_TEMP_CONST)) {
tmp = args[1];
args[1] = args[2];
args[2] = tmp;
--
1.7.10.4
- [Qemu-devel] [PATCH v2 00/10] tcg/optimize: rework copy propagation, Aurelien Jarno, 2012/09/21
- [Qemu-devel] [PATCH v2 06/10] tcg/optimize: optimize "op r, a, a => movi r, 0", Aurelien Jarno, 2012/09/21
- [Qemu-devel] [PATCH v2 08/10] tcg/optimize: prefer the "op a, a, b" form for commutative ops,
Aurelien Jarno <=
- [Qemu-devel] [PATCH v2 01/10] tcg/optimize: remove TCG_TEMP_ANY, Aurelien Jarno, 2012/09/21
- [Qemu-devel] [PATCH v2 10/10] tcg/optimize: add constant folding for deposit, Aurelien Jarno, 2012/09/21
- [Qemu-devel] [PATCH v2 02/10] tcg/optimize: check types in copy propagation, Aurelien Jarno, 2012/09/21
- [Qemu-devel] [PATCH v2 07/10] tcg/optimize: further optimize brcond/movcond/setcond, Aurelien Jarno, 2012/09/21