From patchwork Wed Apr 17 05:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 88568 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EAE8E3858C53 for ; Wed, 17 Apr 2024 05:12:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 93DFA3858D20 for ; Wed, 17 Apr 2024 05:12:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93DFA3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 93DFA3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713330739; cv=none; b=l2ayF/PwNbDE3EW1ERhRFrYGTDPb+TltUsKRcdBuBRjBTRZ05fb8rwXqVr4IgWTF0tOgUpheTk003MMSXAcZOLVvcgPXghCv/v3YLqg5RbGHDqOyw9eFQl76ub5/OMU1X0fJHBp3VyifSfAUoeMr2xRlDHc20IHTl1cscEKrDOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713330739; c=relaxed/simple; bh=qoIGWqpwhzJfE/wsNNooq6X9DyBsjLOGj6hTNRHfPA4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=LWcUwe4cWB2rq1/V8SJASKol0ODHg3xAGThGWMIqJI+wECIKYskEut02cZKJPNP7Oha+0Wmx4Niu6oRWqkrUUsxYMYEiUK+Nizk/KAI1jA9mW+arNHw2sVhokImV1y33h8vvtd134UEoespifAn734T0UHNJAqz7HjbAb10fb30= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43H52PpJ029792; Wed, 17 Apr 2024 05:12:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=xFBaz9qK4sNmioPR3Wr8JBeYhFPwkQzD56+u76bnfX8=; b=nBBfYHuDuKDTl4ZTCWmBiUSx7OiXZDaYt4AB+DBvQblbVZN3vuE1JAhzjqbXlvBBOVho sQhadesZipHbykdOMjzYFDbX6+GRVzI+bKnz20I3BAs0Uc7x50mNno1IR+IPT6IwhdyK 7DNP3XqilHyXh2W85rZRo3wc7W1T3GPH8j5OjX3RrCG/Ja8rn/hU0/0I2EvirRjnC+7z WriHCH+LUZ5iOViZ1bN2oQeirA1Mod9QIRetmsM2tkd7F9uiquKdTJuy5xH3DgvA3nJ6 xGITz9veTQWcqH077ehXPnaJe8nINYbp9r/2ZcD3wAAr/seFIVXSmLhYnPpP2XeB4kud /Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xj7wy00qg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Apr 2024 05:12:14 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43H5CE2L010736; Wed, 17 Apr 2024 05:12:14 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xj7wy00qc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Apr 2024 05:12:14 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43H5A6IN027323; Wed, 17 Apr 2024 05:12:12 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xg4s02hab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Apr 2024 05:12:12 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43H5C7Kf48627978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Apr 2024 05:12:09 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F9AB2004D; Wed, 17 Apr 2024 05:12:05 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B99520049; Wed, 17 Apr 2024 05:12:04 +0000 (GMT) Received: from [9.200.103.244] (unknown [9.200.103.244]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 17 Apr 2024 05:12:03 +0000 (GMT) Message-ID: Date: Wed, 17 Apr 2024 13:12:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner From: HAO CHEN GUI Subject: [PATCH, rs6000] Fix test case bcd4.c X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Eyhvpusp7dPLZuG13gcLr5eBlywLIf17 X-Proofpoint-ORIG-GUID: 6VajNiLsDkzUbif65Top177VsmXVdTZ_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-17_04,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170033 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Hi, This patch fixes loss of return statement in maxbcd of bcd-4.c. Without return statement, it returns an invalid bcd number and make the test noneffective. The patch also enables test to run on Power9 and Big Endian, as all bcd instructions are supported from Power9. Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is it OK for the trunk? Thanks Gui Haochen ChangeLog rs6000: Fix bcd test case gcc/testsuite/ * gcc.target/powerpc/bcd-4.c: Enable the case to be tested on Power9. Enable the case to be run on big endian. Fix function maxbcd and other misc. problems. patch.diff diff --git a/gcc/testsuite/gcc.target/powerpc/bcd-4.c b/gcc/testsuite/gcc.target/powerpc/bcd-4.c index 2c8554dfe82..8c0bac2720f 100644 --- a/gcc/testsuite/gcc.target/powerpc/bcd-4.c +++ b/gcc/testsuite/gcc.target/powerpc/bcd-4.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target power10_hw } */ -/* { dg-options "-mdejagnu-cpu=power10 -O2 -save-temps" } */ +/* { dg-require-effective-target p9vector_hw } */ +/* { dg-options "-mdejagnu-cpu=power9 -O2 -save-temps" } */ /* { dg-final { scan-assembler-times {\mbcdadd\M} 7 } } */ /* { dg-final { scan-assembler-times {\mbcdsub\M} 18 } } */ /* { dg-final { scan-assembler-times {\mbcds\M} 2 } } */ @@ -44,10 +44,20 @@ vector unsigned char maxbcd(unsigned int sign) vector unsigned char result; int i; +#ifdef _BIG_ENDIAN + for (i = 0; i < 15; i++) +#else for (i = 15; i > 0; i--) +#endif result[i] = 0x99; - result[0] = sign << 4 | 0x9; +#ifdef _BIG_ENDIAN + result[15] = 0x90 | sign; +#else + result[0] = 0x90 | sign; +#endif + + return result; } vector unsigned char num2bcd(long int a, int encoding) @@ -70,9 +80,17 @@ vector unsigned char num2bcd(long int a, int encoding) hi = a % 10; // 1st digit a = a / 10; +#ifdef _BIG_ENDIAN + result[15] = hi << 4| sign; +#else result[0] = hi << 4| sign; +#endif +#ifdef _BIG_ENDIAN + for (i = 14; i >= 0; i--) +#else for (i = 1; i < 16; i++) +#endif { low = a % 10; a = a / 10; @@ -117,7 +135,11 @@ int main () } /* result should be positive */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_POS0) +#else if ((result[0] & 0xF) != BCD_POS0) +#endif #if DEBUG printf("ERROR: __builtin_bcdadd sign of result is %d. Does not match " "expected_result = %d\n", @@ -150,7 +172,11 @@ int main () } /* Result should be positive, alternate encoding. */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_POS1) +#else if ((result[0] & 0xF) != BCD_POS1) +#endif #if DEBUG printf("ERROR: __builtin_bcdadd sign of result is %d. Does not " "match expected_result = %d\n", @@ -183,7 +209,11 @@ int main () } /* result should be negative */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_NEG) +#else if ((result[0] & 0xF) != BCD_NEG) +#endif #if DEBUG printf("ERROR: __builtin_bcdadd sign, neg of result is %d. Does not " "match expected_result = %d\n", @@ -217,7 +247,11 @@ int main () } /* result should be positive, alt encoding */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_NEG) +#else if ((result[0] & 0xF) != BCD_NEG) +#endif #if DEBUG printf("ERROR: __builtin_bcdadd sign, of result is %d. Does not match " "expected_result = %d\n", @@ -250,7 +284,11 @@ int main () } /* result should be positive */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_POS1) +#else if ((result[0] & 0xF) != BCD_POS1) +#endif #if DEBUG printf("ERROR: __builtin_bcdsub sign, result is %d. Does not match " "expected_result = %d\n", @@ -283,7 +321,7 @@ int main () abort(); #endif - a = maxbcd(BCD_NEG); + a = maxbcd(BCD_POS0); b = maxbcd(BCD_NEG); if (__builtin_bcdsub_ofl (a, b, 0) == 0) @@ -462,8 +500,12 @@ int main () } /* result should be positive */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_POS0) +#else if ((result[0] & 0xF) != BCD_POS0) -#if 0 +#endif +#if DEBUG printf("ERROR: __builtin_bcdmul10 sign, result is %d. Does not match " "expected_result = %d\n", result[0] & 0xF, BCD_POS1); @@ -492,7 +534,11 @@ int main () } /* result should be positive */ +#ifdef _BIG_ENDIAN + if ((result[15] & 0xF) != BCD_POS0) +#else if ((result[0] & 0xF) != BCD_POS0) +#endif #if DEBUG printf("ERROR: __builtin_bcddiv10 sign, result is %d. Does not match " "expected_result = %d\n",