qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 40/48] tcg/optimize: Expand fold_addsub2_i32 to 64-bit ops


From: Alex Bennée
Subject: Re: [PATCH v2 40/48] tcg/optimize: Expand fold_addsub2_i32 to 64-bit ops
Date: Tue, 19 Oct 2021 16:34:18 +0100
User-agent: mu4e 1.7.0; emacs 28.0.60

Richard Henderson <richard.henderson@linaro.org> writes:

> Rename to fold_addsub2.
> Use Int128 to implement the wider operation.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  tcg/optimize.c | 64 +++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 43 insertions(+), 21 deletions(-)
>
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index 0011ac31ec..5e662ad8f7 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -838,37 +838,59 @@ static bool fold_add(OptContext *ctx, TCGOp *op)
>      return false;
>  }
>  
> -static bool fold_addsub2_i32(OptContext *ctx, TCGOp *op, bool add)
> +static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add)
>  {
>      if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) &&
>          arg_is_const(op->args[4]) && arg_is_const(op->args[5])) {
> -        uint32_t al = arg_info(op->args[2])->val;
> -        uint32_t ah = arg_info(op->args[3])->val;
> -        uint32_t bl = arg_info(op->args[4])->val;
> -        uint32_t bh = arg_info(op->args[5])->val;
> -        uint64_t a = ((uint64_t)ah << 32) | al;
> -        uint64_t b = ((uint64_t)bh << 32) | bl;
> +        uint64_t al = arg_info(op->args[2])->val;
> +        uint64_t ah = arg_info(op->args[3])->val;
> +        uint64_t bl = arg_info(op->args[4])->val;
> +        uint64_t bh = arg_info(op->args[5])->val;
>          TCGArg rl, rh;
> -        TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_mov_i32);
> +        TCGOp *op2;
>  
> -        if (add) {
> -            a += b;
> +        if (ctx->type == TCG_TYPE_I32) {
> +            uint64_t a = deposit64(al, 32, 32, ah);
> +            uint64_t b = deposit64(bl, 32, 32, bh);
> +
> +            if (add) {
> +                a += b;
> +            } else {
> +                a -= b;
> +            }
> +
> +            al = sextract64(a, 0, 32);
> +            ah = sextract64(a, 32, 32);
>          } else {
> -            a -= b;
> +            Int128 a = int128_make128(al, ah);
> +            Int128 b = int128_make128(bl, bh);

This didn't find the Int128 support:

  FAILED: libqemu-arm-linux-user.fa.p/tcg_optimize.c.o 
  cc -m64 -mcx16 -Ilibqemu-arm-linux-user.fa.p -I. -I../.. -Itarget/arm 
-I../../target/arm -I../../linux-user/host/x86_64 -Ilinux-user 
-I../../linux-user -Ilinux-user/arm -I../../linux-user/arm -Itrace -Iqapi -Iui 
-Iui/shader -I/usr/include/capstone -I/usr/include/glib-2.0 
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall 
-Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem 
/home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote . -iquote 
/home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote 
/home/alex/lsrc/qemu.git/disas/libvixl -iquote 
/home/alex/lsrc/qemu.git/tcg/i386 -pthread -U_FORTIFY_SOURCE 
-D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
-Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings 
-Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv 
-Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security 
-Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs 
-Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 
-Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi 
-fstack-protector-strong -fPIE -isystem../../linux-headers 
-isystemlinux-headers -DNEED_CPU_H 
'-DCONFIG_TARGET="arm-linux-user-config-target.h"' 
'-DCONFIG_DEVICES="arm-linux-user-config-devices.h"' -MD -MQ 
libqemu-arm-linux-user.fa.p/tcg_optimize.c.o -MF 
libqemu-arm-linux-user.fa.p/tcg_optimize.c.o.d -o 
libqemu-arm-linux-user.fa.p/tcg_optimize.c.o -c ../../tcg/optimize.c
  ../../tcg/optimize.c: In function ‘fold_addsub2’:
  ../../tcg/optimize.c:865:13: error: unknown type name ‘Int128’
    865 |             Int128 a = int128_make128(al, ah);
        |             ^~~~~~
  ../../tcg/optimize.c:865:24: error: implicit declaration of function 
‘int128_make128’ [-Werror=implicit-function-declaration]
    865 |             Int128 a = int128_make128(al, ah);


possibly we are just missing:

#include "qemu/int128.h"

?

-- 
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]