From patchwork Thu Oct 17 11:28:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 1998513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gjlay.de header.i=@gjlay.de header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=dMucVxpJ; dkim=pass header.d=gjlay.de header.i=@gjlay.de header.a=ed25519-sha256 header.s=strato-dkim-0003 header.b=D+QCOIgj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XTlvv2kXNz1xvV for ; Thu, 17 Oct 2024 22:28:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 98C313858431 for ; Thu, 17 Oct 2024 11:28:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.21]) by sourceware.org (Postfix) with ESMTPS id 95FF23858C35 for ; Thu, 17 Oct 2024 11:28:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 95FF23858C35 Authentication-Results: sourceware.org; dmarc=fail (p=reject dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 95FF23858C35 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=85.215.255.21 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1729164497; cv=pass; b=UHEg672DVDl92QORrbEVmE/t5939nldskuzarQ+6ncoXFQ/w+1Mu05dWLZmlaIpzChxyatoLe+2W6ipVcYvKHqCwCclPV0LNoiN3NHtYuXsUcIYs2v2UNkEc4zMtMyLmInikNg61u+unH6Wh8OPCmD0jlYiwhEwq/J9t4wd7lmg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1729164497; c=relaxed/simple; bh=zGfTxXskbmz+4MTPB5kOHlQvenASNCh8wJjwTVle07w=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=QLsBzyo7ietlfoOEZUXgGSSgLCEZ2XF4tPASy57BuLmW+WAPhmvdaHGWfOjp4aSY+gi0/YdJ4mouWNdvwZ7BFZladvQOYk2puF5e4OA9z5AuRF8iojC3ZY0NbBJFfdDxtnLWVRLaQU8OzlVy+bxG6sg8aRdrG+zOJqgY5SOjDMQ= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1729164481; cv=none; d=strato.com; s=strato-dkim-0002; b=AuS//BXl7M717md4B7LfYcIaRjN7LmIA+E0IKjPM7vsx62xQHpRsT7j0oXU9dmxpR6 r/VcAfD1ZxXVcI6O0FnxoUAj3IWTqZw64R2DAsHJVmfc5HgCdz2UN0G66c4LInub7vYv sGndA/HonXqIukqUxW4YDu7PGXl5bPaQQEEttdOr3D3tSduhR0Iw5X03UR+s89r2F9j0 reIaty0w8pHTiVkKwaJM2cun0qYqNiJ10Tsnfqy0+GzMGQq9/PgTypZfU/g2D2gEa4lE l4QA3nFs7CU7Khv7YqxxJioi4YIERz3D+HBGbwIRYU4naUgQLHPpfSBCkcgYJFJgE+3d tbIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1729164481; s=strato-dkim-0002; d=strato.com; h=In-Reply-To:From:References:To:Subject:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=4l2ouSyRj4RF1Nphj+6+n6WQUeCQpyv3F376uRd8m5Y=; b=qKuTJmN8hSWDGrwGv9GE2sG9gEwa0otIzHA5FmKbNa2oz7U2CfuJUu+65y6y62XDC3 EOI7CmBQRFZcRIyiubDakbB8WaF+5bOgtccMJgvA/LpntvuUYbEmLSh/sF3lmKmSTKcG wPfJFtjXEODL4q4ZYUUT9XFWhOWKaURifhyYWAmU/6KXeSdv1ffvObtetPgGbtVD2Ebx hf7pryyx45QNrr3shusao2KbEzC3il7DGPEf0Ko+N2dHas++KNHTJYioaNipGByfz0nX U0RWuo26ceQr1VDfprIweLHzJyiwjJkubMpHQKTSau+AjPTk0ugeyebpLcMeTku89INn Xc8w== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1729164481; s=strato-dkim-0002; d=gjlay.de; h=In-Reply-To:From:References:To:Subject:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=4l2ouSyRj4RF1Nphj+6+n6WQUeCQpyv3F376uRd8m5Y=; b=dMucVxpJwcEWXEe1KoutSADvOdu0Ra0g38zkWtGS0/bRhlpBH0zQzqtGP2ZI9R8I05 riYyrV8fbC5gy4dhPwz15CPOcNcCcs6IsqKQE0/uqXBAIWtTKVY3OTUgOe0ehARLVxMS mlJCGl3ILfEKxmud1LMnp7vKvU3gCGaqhXD5jmUSX8/FQWI1WebHelpg4nTUE/drE96p uRemdBtjAkAh2z+sTRQfXMfyhjb4DJPXCawUiTJmsJQ//LeNHOg8OGI4vGCWp1jgocCw +s6WfTJu890u867pBZ4JSDAwwh6Vp0jf0yo8AFpAU0gPfxPVpR1kJHlv9vsc3Y1AIRqj Qsog== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1729164481; s=strato-dkim-0003; d=gjlay.de; h=In-Reply-To:From:References:To:Subject:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=4l2ouSyRj4RF1Nphj+6+n6WQUeCQpyv3F376uRd8m5Y=; b=D+QCOIgjO3GAPAPeTuAwyA2Sopi/3Kb+0HckP1wH9wjboi7H3yYQn05goUD99VE2O4 biwyYJQ0+UEXRCx1oSAw== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKXKoq0dKoR0vVqyQb0R7G22gRW+Qr5Q==" Received: from [192.168.2.102] by smtp.strato.de (RZmta 51.2.11 AUTH) with ESMTPSA id xd5faa09HBS1DPg (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 17 Oct 2024 13:28:01 +0200 (CEST) Message-ID: Date: Thu, 17 Oct 2024 13:28:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [patch,avr,applied] Add test cases for PR116550 To: gcc-patches@gcc.gnu.org, Denis Chertykov References: <70ac546b-984c-4f84-9b5c-d3ff71f8cbe9@gmail.com> From: Georg-Johann Lay Content-Language: en-US In-Reply-To: X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_LINEPADDING, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, 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~incoming=patchwork.ozlabs.org@gcc.gnu.org Added two test cases for that PR. Johann --- rtl-optimization/116550 - Add test cases. PR rtl-optimization/116550 gcc/testsuite/ * gcc.target/avr/torture/lra-pr116550-1.c: New file. * gcc.target/avr/torture/lra-pr116550-2.c: New file. rtl-optimization/116550 - Add test cases. PR rtl-optimization/116550 gcc/testsuite/ * gcc.target/avr/torture/lra-pr116550-1.c: New file. * gcc.target/avr/torture/lra-pr116550-2.c: New file. diff --git a/gcc/testsuite/gcc.target/avr/torture/lra-pr116550-1.c b/gcc/testsuite/gcc.target/avr/torture/lra-pr116550-1.c new file mode 100644 index 00000000000..854698c1ec2 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/lra-pr116550-1.c @@ -0,0 +1,216 @@ +/* { dg-additional-options { -std=c99 } } */ + +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); + + +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); + +struct DWstruct {SItype low, high;}; + +typedef union +{ + struct DWstruct s; + DItype ll; +} DWunion; + + +static inline __attribute__ ((__always_inline__)) + +UDItype +__udivmoddi4 (UDItype n, UDItype d, UDItype *rp) +{ + const DWunion nn = {.ll = n}; + const DWunion dd = {.ll = d}; + DWunion rr; + USItype d0, d1, n0, n1, n2; + USItype q0, q1; + USItype b, bm; + + d0 = dd.s.low; + d1 = dd.s.high; + n0 = nn.s.low; + n1 = nn.s.high; + + if (d1 == 0) + { + if (d0 > n1) + { + + + ((bm) = __builtin_clzl (d0)); + + if (bm != 0) + { + + + + d0 = d0 << bm; + n1 = (n1 << bm) | (n0 >> ((4 * 8) - bm)); + n0 = n0 << bm; + } + + do { USItype __d1, __d0, __q1, __q0; USItype __r1, __r0, __m; __d1 = ((USItype) (d0) >> ((4 * 8) / 2)); __d0 = ((USItype) (d0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); __r1 = (n1) % __d1; __q1 = (n1) / __d1; __m = (USItype) __q1 * __d0; __r1 = __r1 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n0) >> ((4 * 8) / 2)); if (__r1 < __m) { __q1--, __r1 += (d0); if (__r1 >= (d0)) if (__r1 < __m) __q1--, __r1 += (d0); } __r1 -= __m; __r0 = __r1 % __d1; __q0 = __r1 / __d1; __m = (USItype) __q0 * __d0; __r0 = __r0 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); if (__r0 < __m) { __q0--, __r0 += (d0); if (__r0 >= (d0)) if (__r0 < __m) __q0--, __r0 += (d0); } __r0 -= __m; (q0) = (USItype) __q1 * ((USItype) 1 << ((4 * 8) / 2)) | __q0; (n0) = __r0; } while (0); + q1 = 0; + + + } + else + { + + + if (d0 == 0) + d0 = 1 / d0; + + ((bm) = __builtin_clzl (d0)); + + if (bm == 0) + { + + + + + + + + n1 -= d0; + q1 = 1; + } + else + { + + + b = (4 * 8) - bm; + + d0 = d0 << bm; + n2 = n1 >> b; + n1 = (n1 << bm) | (n0 >> b); + n0 = n0 << bm; + + do { USItype __d1, __d0, __q1, __q0; USItype __r1, __r0, __m; __d1 = ((USItype) (d0) >> ((4 * 8) / 2)); __d0 = ((USItype) (d0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); __r1 = (n2) % __d1; __q1 = (n2) / __d1; __m = (USItype) __q1 * __d0; __r1 = __r1 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n1) >> ((4 * 8) / 2)); if (__r1 < __m) { __q1--, __r1 += (d0); if (__r1 >= (d0)) if (__r1 < __m) __q1--, __r1 += (d0); } __r1 -= __m; __r0 = __r1 % __d1; __q0 = __r1 / __d1; __m = (USItype) __q0 * __d0; __r0 = __r0 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n1) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); if (__r0 < __m) { __q0--, __r0 += (d0); if (__r0 >= (d0)) if (__r0 < __m) __q0--, __r0 += (d0); } __r0 -= __m; (q1) = (USItype) __q1 * ((USItype) 1 << ((4 * 8) / 2)) | __q0; (n1) = __r0; } while (0); + } + + + + do { USItype __d1, __d0, __q1, __q0; USItype __r1, __r0, __m; __d1 = ((USItype) (d0) >> ((4 * 8) / 2)); __d0 = ((USItype) (d0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); __r1 = (n1) % __d1; __q1 = (n1) / __d1; __m = (USItype) __q1 * __d0; __r1 = __r1 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n0) >> ((4 * 8) / 2)); if (__r1 < __m) { __q1--, __r1 += (d0); if (__r1 >= (d0)) if (__r1 < __m) __q1--, __r1 += (d0); } __r1 -= __m; __r0 = __r1 % __d1; __q0 = __r1 / __d1; __m = (USItype) __q0 * __d0; __r0 = __r0 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); if (__r0 < __m) { __q0--, __r0 += (d0); if (__r0 >= (d0)) if (__r0 < __m) __q0--, __r0 += (d0); } __r0 -= __m; (q0) = (USItype) __q1 * ((USItype) 1 << ((4 * 8) / 2)) | __q0; (n0) = __r0; } while (0); + + + } + + if (rp != 0) + { + rr.s.low = n0 >> bm; + rr.s.high = 0; + *rp = rr.ll; + } + } + + + else + { + if (d1 > n1) + { + + + q0 = 0; + q1 = 0; + + + if (rp != 0) + { + rr.s.low = n0; + rr.s.high = n1; + *rp = rr.ll; + } + } + else + { + + + ((bm) = __builtin_clzl (d1)); + if (bm == 0) + { + + if (n1 > d1 || n0 >= d0) + { + q0 = 1; + do { USItype __x; __x = (n0) - (d0); (n1) = (n1) - (d1) - (__x > (n0)); (n0) = __x; } while (0); + } + else + q0 = 0; + + q1 = 0; + + if (rp != 0) + { + rr.s.low = n0; + rr.s.high = n1; + *rp = rr.ll; + } + } + else + { + USItype m1, m0; + + + b = (4 * 8) - bm; + + d1 = (d1 << bm) | (d0 >> b); + d0 = d0 << bm; + n2 = n1 >> b; + n1 = (n1 << bm) | (n0 >> b); + n0 = n0 << bm; + + do { USItype __d1, __d0, __q1, __q0; USItype __r1, __r0, __m; __d1 = ((USItype) (d1) >> ((4 * 8) / 2)); __d0 = ((USItype) (d1) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); __r1 = (n2) % __d1; __q1 = (n2) / __d1; __m = (USItype) __q1 * __d0; __r1 = __r1 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n1) >> ((4 * 8) / 2)); if (__r1 < __m) { __q1--, __r1 += (d1); if (__r1 >= (d1)) if (__r1 < __m) __q1--, __r1 += (d1); } __r1 -= __m; __r0 = __r1 % __d1; __q0 = __r1 / __d1; __m = (USItype) __q0 * __d0; __r0 = __r0 * ((USItype) 1 << ((4 * 8) / 2)) | ((USItype) (n1) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); if (__r0 < __m) { __q0--, __r0 += (d1); if (__r0 >= (d1)) if (__r0 < __m) __q0--, __r0 += (d1); } __r0 -= __m; (q0) = (USItype) __q1 * ((USItype) 1 << ((4 * 8) / 2)) | __q0; (n1) = __r0; } while (0); + do { USItype __x0, __x1, __x2, __x3; USItype __ul, __vl, __uh, __vh; __ul = ((USItype) (q0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); __uh = ((USItype) (q0) >> ((4 * 8) / 2)); __vl = ((USItype) (d0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); __vh = ((USItype) (d0) >> ((4 * 8) / 2)); __x0 = (USItype) __ul * __vl; __x1 = (USItype) __ul * __vh; __x2 = (USItype) __uh * __vl; __x3 = (USItype) __uh * __vh; __x1 += ((USItype) (__x0) >> ((4 * 8) / 2)); __x1 += __x2; if (__x1 < __x2) __x3 += ((USItype) 1 << ((4 * 8) / 2)); (m1) = __x3 + ((USItype) (__x1) >> ((4 * 8) / 2)); (m0) = ((USItype) (__x1) & (((USItype) 1 << ((4 * 8) / 2)) - 1)) * ((USItype) 1 << ((4 * 8) / 2)) + ((USItype) (__x0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); } while (0); + + if (m1 > n1 || (m1 == n1 && m0 > n0)) + { + q0--; + do { USItype __x; __x = (m0) - (d0); (m1) = (m1) - (d1) - (__x > (m0)); (m0) = __x; } while (0); + } + + q1 = 0; + + + if (rp != 0) + { + do { USItype __x; __x = (n0) - (m0); (n1) = (n1) - (m1) - (__x > (n0)); (n0) = __x; } while (0); + rr.s.low = (n1 << b) | (n0 >> bm); + rr.s.high = n1 >> bm; + *rp = rr.ll; + } + } + } + } + + const DWunion ww = {{.low = q0, .high = q1}}; + return ww.ll; +} + +DItype +__divmoddi4 (DItype u, DItype v, DItype *rp) +{ + SItype c1 = 0, c2 = 0; + DWunion uu = {.ll = u}; + DWunion vv = {.ll = v}; + DItype w; + DItype r; + + if (uu.s.high < 0) + c1 = ~c1, c2 = ~c2, + uu.ll = -uu.ll; + if (vv.s.high < 0) + c1 = ~c1, + vv.ll = -vv.ll; + + w = __udivmoddi4 (uu.ll, vv.ll, (UDItype*)&r); + if (c1) + w = -w; + if (c2) + r = -r; + + *rp = r; + return w; +} diff --git a/gcc/testsuite/gcc.target/avr/torture/lra-pr116550-2.c b/gcc/testsuite/gcc.target/avr/torture/lra-pr116550-2.c new file mode 100644 index 00000000000..a880db5fb46 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/lra-pr116550-2.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ + +typedef int __attribute__((mode(SI))) __attribute__((vector_size (16))) vecint; +typedef int __attribute__((mode(SI))) siint; + +vecint i = { 150, 100, 150, 200 }; +vecint j = { 10, 13, 20, 30 }; +vecint k; + +int main (void) +{ + k = i / j; + /* k = {15, 7, 7, 6} */ + if (k[0] != 15 || k[1] != 7) + __builtin_abort (); + + k = i & j; + /* k = {2, 4, 20, 8} */ + if (k[1] != 4) + __builtin_abort (); + + return 0; +}