From patchwork Wed Apr 22 01:17:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 185642 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp172306ilf; Tue, 21 Apr 2020 18:34:29 -0700 (PDT) X-Google-Smtp-Source: APiQypJhKI6V36APWXnfzRoWQgRQGQ2gLK15gWNUXsoreMUqvPIMaBQimg1KaIja2Icc4MXLsMup X-Received: by 2002:a37:a38b:: with SMTP id m133mr24249038qke.434.1587519269841; Tue, 21 Apr 2020 18:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587519269; cv=none; d=google.com; s=arc-20160816; b=Tf4yzxjL+Z6tbAbFesUmElgZPgw8LU7nrWfntMsoi7HhTuxWsDDQ2MFSgvxIEPfeZu PcfAxbiLDl7gjMqxElTFjBZ2kvh1dSQcSRooOOQBLX1oZSJJveFvxaq99AbFGXYsVXy6 MIpgvAixos9AZDfFnloWdtqW1mBwJssHwZ45XvTVEgmHiLJkG6Ja6eNgW0DOUO2q+sun q+01bFSyTb8R/xTo1ktPoQDiB1HtbqY9xvRrdyvUzlkE6TtiNq3kxwq2ke3KXz1lKsxq by19KTFkav0htAlTDkoVK/1DuCvhP0IuI0ZD+lo9HMWmJEGrh9OHlRmy0n8QH56zTHaK Qa0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=L2VIIPBcFhefaaeb1Q87he02SCE4/igfBVPGh/qdnUE=; b=rtdoyykZUo8djH6LqMV573w5Lm4Hj0jgLdrITT1k8Y3VQju92unWfUUY779XPv7siJ RaRNPGrXaQfXv4uf8zEIyNaJ7XYMSU2KHQaXI4FNJZfuru2m+fv5dKVvDY0GLpWwC0b1 3s7VRm5VIUrxrScWmv5o6JHXS1igD+6QVRWi1bOSR3bTzzr0fooGe/f3Hl18OB75Dbwu eH9MWZ+rOGvxoLDpuM+3DstYkfpp6T1MEwLXDQ6CHnIMTK164fDkeylZUzow3CBHMAxc qpUb9fJbAGgttRxI7UQlWaEAQpaUUBCXsStQYC/lRNfBKrYcLnQC2GjzwXbNwnjwyVdY dlKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r86d0Dmp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ew11si2283888qvb.136.2020.04.21.18.34.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Apr 2020 18:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r86d0Dmp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jR4HV-0004Se-8u for patch@linaro.org; Tue, 21 Apr 2020 21:34:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36416) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jR41n-0002I8-06 for qemu-devel@nongnu.org; Tue, 21 Apr 2020 21:18:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jR41f-0002oI-C2 for qemu-devel@nongnu.org; Tue, 21 Apr 2020 21:18:14 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:44035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jR41e-0002h5-Qi for qemu-devel@nongnu.org; Tue, 21 Apr 2020 21:18:06 -0400 Received: by mail-pf1-x443.google.com with SMTP id p25so207375pfn.11 for ; Tue, 21 Apr 2020 18:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L2VIIPBcFhefaaeb1Q87he02SCE4/igfBVPGh/qdnUE=; b=r86d0DmpfGkrDFRAwkPOEeSsmzFzzYLyfwmIflpiBomt1FmWv0Pbl14B7GxULytcVe qmb+B24AHKP/poi5IqABhSB5XLHSYaMBv4mfa4+0gE71iqZoRCLvpBfiDS9HyC7Nv7Pi cKFNDIIuumA1DeBM5OzXhk90fYPjRruchgq0WFSWCVQtY3PuRgC/us717HvSchifX0tj XiZ4SzX8gc55rOFyKw7Od3Rv35/WzWFW7VNspkPjoyj2TSXqKtzup/6XCuVShZNBZllO 6JaewWMP/DeWu5MFFCsYpQzyONskDpdiKBBpdhDJ7XghCCQYv1Z9jSmZN9FsISpDdRdt rrhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L2VIIPBcFhefaaeb1Q87he02SCE4/igfBVPGh/qdnUE=; b=pcZUzTKY2ArmwacYrrU+hJxojgkf/IFQRGU/ZXNN85JAbvDrGywKOr3mdwxk+wQDNi kLTEoNoLrAXTY7b/ESSm3JWqkzcWf0WDi2ww6mgk44vhCYfe3W8uDgjHnjrcAogUg45e 9K9KTt4HCUJnMlq752I3h/9F+zLjfsOz6g8omcCgGSDHSUTA8yuIPdp2o0K+KDe24JXa aSrWBKEirP7wywxQlT5+4x5LEhdVzjFlumHHnFT6YXNEqmmJaDfPZHPNa9dtx6xjMNUr GjN5WvJE2xjcoJkCV4Xrpt8fD/MgLypRzogqfRQgM7sDdxRkyiYR0itfopxVhQu9kPnB V2zQ== X-Gm-Message-State: AGi0PubE/PrjIn7afeympBH1h0dAMjziKXBUqUuFEayl3hy/UAcpLJj8 Yz/OjkARTCe23lU7F4L/I8cEcwt76CQ= X-Received: by 2002:a65:6250:: with SMTP id q16mr24880006pgv.9.1587518283899; Tue, 21 Apr 2020 18:18:03 -0700 (PDT) Received: from localhost.localdomain (174-21-149-226.tukw.qwest.net. [174.21.149.226]) by smtp.gmail.com with ESMTPSA id m4sm3673561pfm.26.2020.04.21.18.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 18:18:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 32/36] tcg/i386: Implement INDEX_op_rotl[is]_vec Date: Tue, 21 Apr 2020 18:17:18 -0700 Message-Id: <20200422011722.13287-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200422011722.13287-1-richard.henderson@linaro.org> References: <20200422011722.13287-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We must continue the special casing of 8-bit elements and the other element sizes are trivially implemented with shifts. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.inc.c | 85 +++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 16 deletions(-) -- 2.20.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index deace219d2..6039ae4fc6 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -3255,6 +3255,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_shls_vec: case INDEX_op_shrs_vec: case INDEX_op_sars_vec: + case INDEX_op_rotls_vec: case INDEX_op_cmp_vec: case INDEX_op_x86_shufps_vec: case INDEX_op_x86_blend_vec: @@ -3293,6 +3294,7 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_xor_vec: case INDEX_op_andc_vec: return 1; + case INDEX_op_rotli_vec: case INDEX_op_cmp_vec: case INDEX_op_cmpsel_vec: return -1; @@ -3316,6 +3318,7 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_shls_vec: case INDEX_op_shrs_vec: + case INDEX_op_rotls_vec: return vece >= MO_16; case INDEX_op_sars_vec: return vece >= MO_16 && vece <= MO_32; @@ -3353,7 +3356,7 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) } } -static void expand_vec_shi(TCGType type, unsigned vece, bool shr, +static void expand_vec_shi(TCGType type, unsigned vece, TCGOpcode opc, TCGv_vec v0, TCGv_vec v1, TCGArg imm) { TCGv_vec t1, t2; @@ -3363,26 +3366,31 @@ static void expand_vec_shi(TCGType type, unsigned vece, bool shr, t1 = tcg_temp_new_vec(type); t2 = tcg_temp_new_vec(type); - /* Unpack to W, shift, and repack. Tricky bits: - (1) Use punpck*bw x,x to produce DDCCBBAA, - i.e. duplicate in other half of the 16-bit lane. - (2) For right-shift, add 8 so that the high half of - the lane becomes zero. For left-shift, we must - shift up and down again. - (3) Step 2 leaves high half zero such that PACKUSWB - (pack with unsigned saturation) does not modify - the quantity. */ + /* + * Unpack to W, shift, and repack. Tricky bits: + * (1) Use punpck*bw x,x to produce DDCCBBAA, + * i.e. duplicate in other half of the 16-bit lane. + * (2) For right-shift, add 8 so that the high half of the lane + * becomes zero. For left-shift, and left-rotate, we must + * shift up and down again. + * (3) Step 2 leaves high half zero such that PACKUSWB + * (pack with unsigned saturation) does not modify + * the quantity. + */ vec_gen_3(INDEX_op_x86_punpckl_vec, type, MO_8, tcgv_vec_arg(t1), tcgv_vec_arg(v1), tcgv_vec_arg(v1)); vec_gen_3(INDEX_op_x86_punpckh_vec, type, MO_8, tcgv_vec_arg(t2), tcgv_vec_arg(v1), tcgv_vec_arg(v1)); - if (shr) { - tcg_gen_shri_vec(MO_16, t1, t1, imm + 8); - tcg_gen_shri_vec(MO_16, t2, t2, imm + 8); + if (opc != INDEX_op_rotli_vec) { + imm += 8; + } + if (opc == INDEX_op_shri_vec) { + tcg_gen_shri_vec(MO_16, t1, t1, imm); + tcg_gen_shri_vec(MO_16, t2, t2, imm); } else { - tcg_gen_shli_vec(MO_16, t1, t1, imm + 8); - tcg_gen_shli_vec(MO_16, t2, t2, imm + 8); + tcg_gen_shli_vec(MO_16, t1, t1, imm); + tcg_gen_shli_vec(MO_16, t2, t2, imm); tcg_gen_shri_vec(MO_16, t1, t1, 8); tcg_gen_shri_vec(MO_16, t2, t2, 8); } @@ -3449,6 +3457,43 @@ static void expand_vec_sari(TCGType type, unsigned vece, } } +static void expand_vec_rotli(TCGType type, unsigned vece, + TCGv_vec v0, TCGv_vec v1, TCGArg imm) +{ + TCGv_vec t; + + if (vece == MO_8) { + expand_vec_shi(type, vece, INDEX_op_rotli_vec, v0, v1, imm); + return; + } + + t = tcg_temp_new_vec(type); + tcg_gen_shli_vec(vece, t, v1, imm); + tcg_gen_shri_vec(vece, v0, v1, (8 << vece) - imm); + tcg_gen_or_vec(vece, v0, v0, t); + tcg_temp_free_vec(t); +} + +static void expand_vec_rotls(TCGType type, unsigned vece, + TCGv_vec v0, TCGv_vec v1, TCGv_i32 lsh) +{ + TCGv_i32 rsh; + TCGv_vec t; + + tcg_debug_assert(vece != MO_8); + + t = tcg_temp_new_vec(type); + rsh = tcg_temp_new_i32(); + + tcg_gen_neg_i32(rsh, lsh); + tcg_gen_andi_i32(rsh, rsh, (8 << vece) - 1); + tcg_gen_shls_vec(vece, t, v1, lsh); + tcg_gen_shrs_vec(vece, v0, v1, rsh); + tcg_gen_or_vec(vece, v0, v0, t); + tcg_temp_free_vec(t); + tcg_temp_free_i32(rsh); +} + static void expand_vec_mul(TCGType type, unsigned vece, TCGv_vec v0, TCGv_vec v1, TCGv_vec v2) { @@ -3658,13 +3703,21 @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, switch (opc) { case INDEX_op_shli_vec: case INDEX_op_shri_vec: - expand_vec_shi(type, vece, opc == INDEX_op_shri_vec, v0, v1, a2); + expand_vec_shi(type, vece, opc, v0, v1, a2); break; case INDEX_op_sari_vec: expand_vec_sari(type, vece, v0, v1, a2); break; + case INDEX_op_rotli_vec: + expand_vec_rotli(type, vece, v0, v1, a2); + break; + + case INDEX_op_rotls_vec: + expand_vec_rotls(type, vece, v0, v1, temp_tcgv_i32(arg_temp(a2))); + break; + case INDEX_op_mul_vec: v2 = temp_tcgv_vec(arg_temp(a2)); expand_vec_mul(type, vece, v0, v1, v2);