From patchwork Thu Jun 15 16:00:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 108607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp741412vqr; Thu, 15 Jun 2023 09:01:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4yZHiyhHeWlzVy6hwOvhUSyIeufSjTEZbR7lEukl/zm3us6jBFokls0OwHiy3u6CqNpVxt X-Received: by 2002:a17:906:99c3:b0:96f:d345:d100 with SMTP id s3-20020a17090699c300b0096fd345d100mr15910922ejn.59.1686844912590; Thu, 15 Jun 2023 09:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686844912; cv=none; d=google.com; s=arc-20160816; b=hO28l+SWtRNOzjgqz4kSAcEP6se3Fsg3L+GywuEF8DeO9iVLh7wCHJsz4ohCwI3y95 RMAb23o8ZcZrztnqkG0BoLyLfp/RT8OjGIy4Wlc6iZSjzznuWvZiLnBNSSiB9f3d/NDS KWjDO5fGxZP9tbXxgvSigsWrfV1A0qfEtWes0AzFhMAnODmHBTZLXv+wzm4UxPIhOiQq J2qSGBy7zHG1IyBYV5eQWwNzEhTaECdYeY/9H1YOlf9AFQ0twzuKpRAXdP21TfKjrpwZ 2oHn/gv+kQkyYamQXD+hoi1eaqHDsmUZuNzMOSjvuAawV6cgCleRvLBGaMDbX5ZWr7/J 8hOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:date:cc:to:subject :message-id:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=mYxubvV3PLxFs7KspyZnbzVD6H6uAoWhUXl3MzqJjTg=; b=cGY/Kf13QeIhucjUTvZL9i/0jiQiiXVgQDgU18AvNJhRdymgVA9Tm73DmmxonmwHzf lV5tvimL8ns15haD09/xjULpmXhZ9hov5H6wNPhULyWZ0gV+X4JDfFmiOyKEjWlu2nPV o8yjNGtUnFslqHh/eOyGDEMMak0Q2oYOXeC+Z5vq/QQxW/9UCD4tb6UZ9iHkAxdrlbQ4 Ka6Gu02URm2st9tFnhY+BMyoW2XI1gHD/NURwjhHm5TKPPH4GF5DdoWQilC8XN3rrE76 thdOJXYBB6HWIFoo8En27Jmq52W7ShfTwYV8rwZnqtQRszL9ydHv/quQz5/cii8pItFG qf3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ESwQZqpJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id jo11-20020a170906f6cb00b00977e0fbf8d8si9603760ejb.294.2023.06.15.09.01.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 09:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ESwQZqpJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B973B3854E70 for ; Thu, 15 Jun 2023 16:01:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B973B3854E70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686844889; bh=mYxubvV3PLxFs7KspyZnbzVD6H6uAoWhUXl3MzqJjTg=; h=Subject:To:Cc:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ESwQZqpJtaMxJUqySCvkE6pPl7uWvswdFQV6NpVWc04K+ciEa7BkZI7kD9kAYfvdC mRkDi6bTNW0hG1/Bz+PQ3ryqgcULxGa/ImA2jvJFMqUcKV5JV8SdxRF9grpu+lIBMB iBQQnxEDTQXO4mBnLNiabtT/4iuZlstbbBqLmAIY= 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 600B73857BA4 for ; Thu, 15 Jun 2023 16:00:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 600B73857BA4 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35FFeIYo021537; Thu, 15 Jun 2023 16:00:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r8549hfhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jun 2023 16:00:40 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35FFeA4A020855; Thu, 15 Jun 2023 16:00:40 GMT Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r8549hfgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jun 2023 16:00:39 +0000 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35FDk23f002806; Thu, 15 Jun 2023 16:00:38 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([9.208.130.98]) by ppma03wdc.us.ibm.com (PPS) with ESMTPS id 3r4gt5ujs6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Jun 2023 16:00:38 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35FG0aKO48234844 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Jun 2023 16:00:37 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE87B5805F; Thu, 15 Jun 2023 16:00:36 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDF5758059; Thu, 15 Jun 2023 16:00:35 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.61.18.149]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 15 Jun 2023 16:00:35 +0000 (GMT) Message-ID: <004d44c3139e2af8c70ed57a4cb813a6b1cf3d67.camel@us.ibm.com> Subject: [PATCH ver 2] rs6000, fix vec_replace_unaligned builtin arguments To: "Kewen.Lin" , cel@us.ibm.com Cc: Peter Bergner , Segher Boessenkool , gcc-patches@gcc.gnu.org, David Edelsohn Date: Thu, 15 Jun 2023 09:00:35 -0700 X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Zc82neDHN9yl8kETh8teqT_T-aWWJfua X-Proofpoint-GUID: kWGiFpZaeS9fTM5gFOtVmFyYdPySrBZS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-15_12,2023-06-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 clxscore=1015 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306150136 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Carl Love via Gcc-patches From: Carl Love Reply-To: Carl Love Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768785091112011581?= X-GMAIL-MSGID: =?utf-8?q?1768785091112011581?= GCC maintainers: Version 2, fixed various typos. Updated the change log body to say the instruction counts were updated. The instruction counts changed as a result of changing the first argument of the vec_replace_unaligned builtin call from vector unsigned long long (vull) to vector unsigned char (vuc). When the first argument was vull the builtin call generated the vinsd instruction for the two test cases. The updated call with vuc as the first argument generates two vinsw instructions instead. Patch was retested on Power 10 with no regressions. The following patch fixes the first argument in the builtin definition and the corresponding test cases. Initially, the builtin specification was wrong due to a cut and past error. The documentation was fixed in: commit ed3fea09b18f67e757b5768b42cb6e816626f1db Author: Bill Schmidt Date: Fri Feb 4 13:07:17 2022 -0600 rs6000: Correct function prototypes for vec_replace_unaligned Due to a pasto error in the documentation, vec_replace_unaligned was implemented with the same function prototypes as vec_replace_elt. It was intended that vec_replace_unaligned always specify output vectors as having type vector unsigned char, to emphasize that elements are potentially misaligned by this built-in function. This patch corrects the misimplementation. .... This patch fixes the arguments in the definitions and updates the testcases accordingly. Additionally, a few minor spacing issues are fixed. The patch has been tested on Power 10 with no regressions. Please let me know if the patch is acceptable for mainline. Thanks. Carl -------------------------------------------------- rs6000, fix vec_replace_unaligned builtin arguments The first argument of the vec_replace_unaligned builtin should always be unsigned char, as specified in gcc/doc/extend.texi. This patch fixes the builtin definitions and updates the testcases to use the correct arguments. The expected instruction counts for the testcase are updated. gcc/ChangeLog: * config/rs6000/rs6000-overload.def (__builtin_vec_replace_un): Fix first argument type. gcc/testsuite/ChangeLog: * gcc.target/powerpc/ver-replace-word-runnable.c (vec_replace_unaligned) Fix first argument type. (vresult_uchar): Fix expected results. (vec_replace_unaligned): Update for loop to check uchar results. Remove extra spaces in if statements. Insert missing spaces in for statements. (dg-final): Update expected instruction counts. --- gcc/config/rs6000/rs6000-overload.def | 12 +- .../powerpc/vec-replace-word-runnable.c | 157 ++++++++++-------- 2 files changed, 92 insertions(+), 77 deletions(-) diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index c582490c084..26dc662b8fb 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -3059,17 +3059,17 @@ VREPLACE_ELT_V2DF [VEC_REPLACE_UN, vec_replace_unaligned, __builtin_vec_replace_un] - vuc __builtin_vec_replace_un (vui, unsigned int, const int); + vuc __builtin_vec_replace_un (vuc, unsigned int, const int); VREPLACE_UN_UV4SI - vuc __builtin_vec_replace_un (vsi, signed int, const int); + vuc __builtin_vec_replace_un (vuc, signed int, const int); VREPLACE_UN_V4SI - vuc __builtin_vec_replace_un (vull, unsigned long long, const int); + vuc __builtin_vec_replace_un (vuc, unsigned long long, const int); VREPLACE_UN_UV2DI - vuc __builtin_vec_replace_un (vsll, signed long long, const int); + vuc __builtin_vec_replace_un (vuc, signed long long, const int); VREPLACE_UN_V2DI - vuc __builtin_vec_replace_un (vf, float, const int); + vuc __builtin_vec_replace_un (vuc, float, const int); VREPLACE_UN_V4SF - vuc __builtin_vec_replace_un (vd, double, const int); + vuc __builtin_vec_replace_un (vuc, double, const int); VREPLACE_UN_V2DF [VEC_REVB, vec_revb, __builtin_vec_revb] diff --git a/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c b/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c index 27318822871..66b0ef58996 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c @@ -20,6 +20,9 @@ main (int argc, char *argv []) unsigned char ch; unsigned int index; + vector unsigned char src_va_uchar; + vector unsigned char expected_vresult_uchar; + vector unsigned int vresult_uint; vector unsigned int expected_vresult_uint; vector unsigned int src_va_uint; @@ -64,10 +67,10 @@ main (int argc, char *argv []) vresult_uint = vec_replace_elt (src_va_uint, src_a_uint, 2); - if (!vec_all_eq (vresult_uint, expected_vresult_uint)) { + if (!vec_all_eq (vresult_uint, expected_vresult_uint)) { #if DEBUG printf("ERROR, vec_replace_elt (src_vb_uint, src_va_uint, index)\n"); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) printf(" vresult_uint[%d] = %d, expected_vresult_uint[%d] = %d\n", i, vresult_uint[i], i, expected_vresult_uint[i]); #else @@ -82,10 +85,10 @@ main (int argc, char *argv []) vresult_int = vec_replace_elt (src_va_int, src_a_int, 1); - if (!vec_all_eq (vresult_int, expected_vresult_int)) { + if (!vec_all_eq (vresult_int, expected_vresult_int)) { #if DEBUG printf("ERROR, vec_replace_elt (src_vb_int, src_va_int, index)\n"); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n", i, vresult_int[i], i, expected_vresult_int[i]); #else @@ -100,10 +103,10 @@ main (int argc, char *argv []) vresult_float = vec_replace_elt (src_va_float, src_a_float, 1); - if (!vec_all_eq (vresult_float, expected_vresult_float)) { + if (!vec_all_eq (vresult_float, expected_vresult_float)) { #if DEBUG printf("ERROR, vec_replace_elt (src_vb_float, src_va_float, index)\n"); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) printf(" vresult_float[%d] = %f, expected_vresult_float[%d] = %f\n", i, vresult_float[i], i, expected_vresult_float[i]); #else @@ -122,7 +125,7 @@ main (int argc, char *argv []) if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) { #if DEBUG printf("ERROR, vec_replace_elt (src_vb_ullint, src_va_ullint, index)\n"); - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n", i, vresult_ullint[i], i, expected_vresult_ullint[i]); #else @@ -137,10 +140,10 @@ main (int argc, char *argv []) vresult_llint = vec_replace_elt (src_va_llint, src_a_llint, 1); - if (!vec_all_eq (vresult_llint, expected_vresult_llint)) { + if (!vec_all_eq (vresult_llint, expected_vresult_llint)) { #if DEBUG printf("ERROR, vec_replace_elt (src_vb_llint, src_va_llint, index)\n"); - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) printf(" vresult_llint[%d] = %d, expected_vresult_llint[%d] = %d\n", i, vresult_llint[i], i, expected_vresult_llint[i]); #else @@ -155,10 +158,10 @@ main (int argc, char *argv []) vresult_double = vec_replace_elt (src_va_double, src_a_double, 1); - if (!vec_all_eq (vresult_double, expected_vresult_double)) { + if (!vec_all_eq (vresult_double, expected_vresult_double)) { #if DEBUG printf("ERROR, vec_replace_elt (src_vb_double, src_va_double, index)\n"); - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) printf(" vresult_double[%d] = %f, expected_vresult_double[%d] = %f\n", i, vresult_double[i], i, expected_vresult_double[i]); #else @@ -169,60 +172,68 @@ main (int argc, char *argv []) /* Vector replace 32-bit element, unaligned */ src_a_uint = 345; - src_va_uint = (vector unsigned int) { 1, 2, 0, 0 }; - vresult_uint = (vector unsigned int) { 0, 0, 0, 0 }; + src_va_uchar = (vector unsigned char) { 1, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; /* Byte index 7 will overwrite part of elements 2 and 3 */ - expected_vresult_uint = (vector unsigned int) { 1, 2, 345*256, 0 }; + expected_vresult_uchar + = (vector unsigned char) { 1, 0, 0, 0, 2, 0, 0, 0, + 0, 0x59, 0x1, 0, 0, 0, 0, 0 }; - vresult_uchar = vec_replace_unaligned (src_va_uint, src_a_uint, 3); - vresult_uint = (vector unsigned int) vresult_uchar; + vresult_uchar = vec_replace_unaligned (src_va_uchar, src_a_uint, 3); - if (!vec_all_eq (vresult_uint, expected_vresult_uint)) { + if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { #if DEBUG - printf("ERROR, vec_replace_unaligned (src_vb_uint, src_va_uint, index)\n"); - for(i = 0; i < 4; i++) - printf(" vresult_uint[%d] = %d, expected_vresult_uint[%d] = %d\n", - i, vresult_uint[i], i, expected_vresult_uint[i]); + printf("ERROR, vec_replace_unaligned (src_va_uchar, src_va_uint, index)\n"); + for (i = 0; i < 16; i++) + printf(" vresult_uchar[%d] = 0x%x, expected_vresult_uint[%d] = 0%x\n", + i, vresult_uchar[i], i, expected_vresult_uchar[i]); #else abort(); #endif } src_a_int = 234; - src_va_int = (vector int) { 1, 0, 3, 4 }; - vresult_int = (vector int) { 0, 0, 0, 0 }; + src_va_uchar = (vector unsigned char) { 1, 0, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, 0, 0 }; + vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; /* Byte index 7 will over write part of elements 1 and 2 */ - expected_vresult_int = (vector int) { 1, 234*256, 0, 4 }; - - vresult_uchar = vec_replace_unaligned (src_va_int, src_a_int, 7); - vresult_int = (vector signed int) vresult_uchar; + expected_vresult_uchar = (vector unsigned char) { 1, 0, 0, 0, 0, 0xea, 0, 0, + 0, 0, 0, 0, 4, 0, 0, 0 }; - if (!vec_all_eq (vresult_int, expected_vresult_int)) { + vresult_uchar = vec_replace_unaligned (src_va_uchar, src_a_int, 7); + + if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { #if DEBUG - printf("ERROR, vec_replace_unaligned (src_vb_int, src_va_int, index)\n"); - for(i = 0; i < 4; i++) - printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n", - i, vresult_int[i], i, expected_vresult_int[i]); + printf("ERROR, vec_replace_unaligned (src_va_uchar, src_va_int, index)\n"); + for (i = 0; i < 16; i++) + printf(" vresult_int[%d] = 0x%x, expected_vresult_int[%d] = 0x%x\n", + i, vresult_uchar[i], i, expected_vresult_uchar[i]); #else abort(); #endif } src_a_float = 34.0; - src_va_float = (vector float) { 0.0, 10.0, 20.0, 30.0 }; - vresult_float = (vector float) { 0.0, 0.0, 0.0, 0.0 }; - expected_vresult_float = (vector float) { 0.0, 34.0, 20.0, 30.0 }; + src_va_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0x41, 0xa0, + 5, 6, 7, 8, 0x41, 0xf0, 0, 0}; + vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + expected_vresult_uchar + = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 8, 0x42, + 5, 6, 7, 8, 0x41, 0xf0, 0, 0 }; - vresult_uchar = vec_replace_unaligned (src_va_float, src_a_float, 8); - vresult_float = (vector float) vresult_uchar; + vresult_uchar = vec_replace_unaligned (src_va_uchar, src_a_float, 8); - if (!vec_all_eq (vresult_float, expected_vresult_float)) { + if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { #if DEBUG - printf("ERROR, vec_replace_unaligned (src_vb_float, src_va_float, " + printf("ERROR, vec_replace_unaligned (src_va_uchar, src_va_float, " "index)\n"); - for(i = 0; i < 4; i++) - printf(" vresult_float[%d] = %f, expected_vresult_float[%d] = %f\n", - i, vresult_float[i], i, expected_vresult_float[i]); + for (i = 0; i < 16; i++) + printf(" vresult_uchar[%d] = 0x%x, expected_vresult_uchar[%d] = 0x%x\n", + i, vresult_uchar[i], i, expected_vresult_uchar[i]); #else abort(); #endif @@ -230,61 +241,67 @@ main (int argc, char *argv []) /* Vector replace 64-bit element, unaligned */ src_a_ullint = 456; - src_va_ullint = (vector unsigned long long int) { 0, 0x222 }; - vresult_ullint = (vector unsigned long long int) { 0, 0 }; - expected_vresult_ullint = (vector unsigned long long int) { 456*256, - 0x200 }; + src_va_uchar = (vector unsigned char) { 0, 0xc, 0x1, 0, 0, 0, 0, 0, + 0x22, 0x2, 0, 0, 0, 0, 0, 0 }; + vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + expected_vresult_uchar + = (vector unsigned char) { 0, 0xc, 0x1, 0, 0, 0xc8, 1, 0, + 0, 2, 0, 0, 0, 0, 0, 0 }; /* Byte index 7 will over write least significant byte of element 0 */ - vresult_uchar = vec_replace_unaligned (src_va_ullint, src_a_ullint, 7); - vresult_ullint = (vector unsigned long long) vresult_uchar; + vresult_uchar = vec_replace_unaligned (src_va_uchar, src_a_ullint, 7); - if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) { + if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { #if DEBUG - printf("ERROR, vec_replace_unaligned (src_vb_ullint, src_va_ullint, " + printf("ERROR, vec_replace_unaligned (src_va_uchar, src_va_ullint, " "index)\n"); - for(i = 0; i < 2; i++) - printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n", - i, vresult_ullint[i], i, expected_vresult_ullint[i]); + for (i = 0; i < 15; i++) + printf(" vresult_uchar[%d] = 0x%x, expected_vresult_uchar[%d] = 0x%x\n", + i, vresult_uchar[i], i, expected_vresult_uchar[i]); #else abort(); #endif } src_a_llint = 678; - src_va_llint = (vector long long int) { 0, 0x101 }; + src_va_uchar = (vector unsigned char) { 0, 0xa6, 0x2, 0, 0, 0, 0, 0, + 0x0, 0x1, 0, 0, 0, 0, 0, 0 }; vresult_llint = (vector long long int) { 0, 0 }; /* Byte index 7 will over write least significant byte of element 0 */ - expected_vresult_llint = (vector long long int) { 678*256, 0x100 }; + expected_vresult_uchar + = (vector unsigned char) { 0x0, 0xa6, 0x2, 0x0, 0x0, 0xa6, 0x2, 0x0, + 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; - vresult_uchar = vec_replace_unaligned (src_va_llint, src_a_llint, 7); - vresult_llint = (vector signed long long) vresult_uchar; + vresult_uchar = vec_replace_unaligned (src_va_uchar, src_a_llint, 7); - if (!vec_all_eq (vresult_llint, expected_vresult_llint)) { + if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { #if DEBUG - printf("ERROR, vec_replace_unaligned (src_vb_llint, src_va_llint, " + printf("ERROR, vec_replace_unaligned (src_va_uchar, src_va_llint, " "index)\n"); - for(i = 0; i < 2; i++) - printf(" vresult_llint[%d] = %d, expected_vresult_llint[%d] = %d\n", - i, vresult_llint[i], i, expected_vresult_llint[i]); + for (i = 0; i < 16; i++) + printf(" vresult_uchar[%d] = %d, expected_vresult_uchar[%d] = %d\n", + i, vresult_uchar[i], i, expected_vresult_uchar[i]); #else abort(); #endif } src_a_double = 678.0; - src_va_double = (vector double) { 0.0, 50.0 }; + // src_va_double = (vector double) { 0.0, 50.0 }; + src_va_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; vresult_double = (vector double) { 0.0, 0.0 }; expected_vresult_double = (vector double) { 0.0, 678.0 }; - vresult_uchar = vec_replace_unaligned (src_va_double, src_a_double, 0); + vresult_uchar = vec_replace_unaligned (src_va_uchar, src_a_double, 0); vresult_double = (vector double) vresult_uchar; - if (!vec_all_eq (vresult_double, expected_vresult_double)) { + if (!vec_all_eq (vresult_double, expected_vresult_double)) { #if DEBUG - printf("ERROR, vec_replace_unaligned (src_vb_double, src_va_double, " + printf("ERROR, vec_replace_unaligned (src_va_uchar, src_va_double, " "index)\n"); - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) printf(" vresult_double[%d] = %f, expected_vresult_double[%d] = %f\n", i, vresult_double[i], i, expected_vresult_double[i]); #else @@ -295,7 +312,5 @@ main (int argc, char *argv []) return 0; } -/* { dg-final { scan-assembler-times {\mvinsw\M} 6 } } */ -/* { dg-final { scan-assembler-times {\mvinsd\M} 6 } } */ - - +/* { dg-final { scan-assembler-times {\mvinsw\M} 8 } } */ +/* { dg-final { scan-assembler-times {\mvinsd\M} 4 } } */