From patchwork Thu Jun 17 21:52:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 12329613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 932D6C48BE5 for ; Thu, 17 Jun 2021 21:54:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D82361241 for ; Thu, 17 Jun 2021 21:54:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D82361241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltzxh-000797-B1 for qemu-devel@archiver.kernel.org; Thu, 17 Jun 2021 17:54:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltzwR-00055g-TP for qemu-devel@nongnu.org; Thu, 17 Jun 2021 17:52:51 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:58027) by eggs.gnu.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ltzwP-0006ef-Sp for qemu-devel@nongnu.org; Thu, 17 Jun 2021 17:52:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1623966769; x=1655502769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sj+nSkX76zU4l1vDrDXCMayA9ZQqFoOnXfk1J3sChBU=; b=p2euMzw21BfhK7oOv3dmQw5Sweq7Wx56CosHDRADwd0aVR65RI0i7Yxi twH6Oycij4VTYmoVlkPUB0saFEDMns/7rmlc0uqa580nAjb7s3DZV7ylJ V5uDkx00PjnTs5qcdqnZY75E6xjG9OKVbVLWFpGR60/2isP4VZ9topdFe I=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 17 Jun 2021 14:52:44 -0700 X-QCInternal: smtphost Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg02-sd.qualcomm.com with ESMTP; 17 Jun 2021 14:52:43 -0700 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id A4485F3D; Thu, 17 Jun 2021 16:52:43 -0500 (CDT) From: Taylor Simpson To: tsimpson@quicinc.com Subject: [PULL 1/4] Hexagon (target/hexagon) fix bug in fLSBNEW* Date: Thu, 17 Jun 2021 16:52:32 -0500 Message-Id: <1623966755-30225-2-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623966755-30225-1-git-send-email-tsimpson@quicinc.com> References: <1623966755-30225-1-git-send-email-tsimpson@quicinc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=199.106.114.39; envelope-from=tsimpson@qualcomm.com; helo=alexa-out-sd-02.qualcomm.com X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "open list:All patches CC here" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Change fLSBNEW/fLSBNEW0/fLSBNEW1 from copy to "x & 1" Remove gen_logical_not function Clean up fLSBNEWNOT to use andi-1 followed by xori-1 Test cases added to tests/tcg/hexagon/misc.c Reviewed-by: Richard Henderson Signed-off-by: Taylor Simpson --- target/hexagon/macros.h | 27 ++++++++++----------------- target/hexagon/op_helper.c | 5 ----- tests/tcg/hexagon/misc.c | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index b726c3b..2b208f3 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -239,33 +239,26 @@ static inline void gen_pred_cancel(TCGv pred, int slot_num) #endif #ifdef QEMU_GENERATE -#define fLSBNEW(PVAL) tcg_gen_mov_tl(LSB, (PVAL)) -#define fLSBNEW0 tcg_gen_mov_tl(LSB, hex_new_pred_value[0]) -#define fLSBNEW1 tcg_gen_mov_tl(LSB, hex_new_pred_value[1]) +#define fLSBNEW(PVAL) tcg_gen_andi_tl(LSB, (PVAL), 1) +#define fLSBNEW0 tcg_gen_andi_tl(LSB, hex_new_pred_value[0], 1) +#define fLSBNEW1 tcg_gen_andi_tl(LSB, hex_new_pred_value[1], 1) #else -#define fLSBNEW(PVAL) (PVAL) -#define fLSBNEW0 new_pred_value(env, 0) -#define fLSBNEW1 new_pred_value(env, 1) +#define fLSBNEW(PVAL) ((PVAL) & 1) +#define fLSBNEW0 (env->new_pred_value[0] & 1) +#define fLSBNEW1 (env->new_pred_value[1] & 1) #endif #ifdef QEMU_GENERATE -static inline void gen_logical_not(TCGv dest, TCGv src) -{ - TCGv one = tcg_const_tl(1); - TCGv zero = tcg_const_tl(0); - - tcg_gen_movcond_tl(TCG_COND_NE, dest, src, zero, zero, one); - - tcg_temp_free(one); - tcg_temp_free(zero); -} #define fLSBOLDNOT(VAL) \ do { \ tcg_gen_andi_tl(LSB, (VAL), 1); \ tcg_gen_xori_tl(LSB, LSB, 1); \ } while (0) #define fLSBNEWNOT(PNUM) \ - gen_logical_not(LSB, (PNUM)) + do { \ + tcg_gen_andi_tl(LSB, (PNUM), 1); \ + tcg_gen_xori_tl(LSB, LSB, 1); \ + } while (0) #else #define fLSBNEWNOT(PNUM) (!fLSBNEW(PNUM)) #define fLSBOLDNOT(VAL) (!fLSBOLD(VAL)) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 63dd685..4595559 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -128,11 +128,6 @@ void HELPER(debug_start_packet)(CPUHexagonState *env) } } -static int32_t new_pred_value(CPUHexagonState *env, int pnum) -{ - return env->new_pred_value[pnum]; -} - /* Checks for bookkeeping errors between disassembly context and runtime */ void HELPER(debug_check_store_width)(CPUHexagonState *env, int slot, int check) { diff --git a/tests/tcg/hexagon/misc.c b/tests/tcg/hexagon/misc.c index 17c3919..9e139f3 100644 --- a/tests/tcg/hexagon/misc.c +++ b/tests/tcg/hexagon/misc.c @@ -181,6 +181,19 @@ static inline void S4_storeirifnew_io(void *p, int pred) : "p0", "memory"); } +static int L2_ploadrifnew_pi(void *p, int pred) +{ + int result; + asm volatile("%0 = #31\n\t" + "{\n\t" + " p0 = cmp.eq(%1, #1)\n\t" + " if (!p0.new) %0 = memw(%2++#4)\n\t" + "}\n\t" + : "=r"(result) : "r"(pred), "r"(p) + : "p0"); + return result; +} + /* * Test that compound-compare-jump is executed in 2 parts * First we have to do all the compares in the packet and @@ -298,8 +311,24 @@ static int auto_and(void) return retval; } +void test_lsbnew(void) +{ + int result; + + asm("r0 = #2\n\t" + "r1 = #5\n\t" + "{\n\t" + " p0 = r0\n\t" + " if (p0.new) r1 = #3\n\t" + "}\n\t" + "%0 = r1\n\t" + : "=r"(result) :: "r0", "r1", "p0"); + check(result, 5); +} + int main() { + int res; long long res64; int pred; @@ -394,6 +423,12 @@ int main() S4_storeirifnew_io(&array[8], 1); check(array[9], 9); + memcpy(array, init, sizeof(array)); + res = L2_ploadrifnew_pi(&array[6], 0); + check(res, 6); + res = L2_ploadrifnew_pi(&array[7], 1); + check(res, 31); + int x = cmpnd_cmp_jump(); check(x, 12); @@ -406,7 +441,7 @@ int main() check((int)pair, 5); check((int)(pair >> 32), 7); - int res = test_clrtnew(1, 7); + res = test_clrtnew(1, 7); check(res, 0); res = test_clrtnew(2, 7); check(res, 7); @@ -422,6 +457,8 @@ int main() res = auto_and(); check(res, 0); + test_lsbnew(); + puts(err ? "FAIL" : "PASS"); return err; }