From patchwork Tue Dec 14 15:28:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 48902 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 139D63857C70 for ; Tue, 14 Dec 2021 15:28:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 80FDE3858001 for ; Tue, 14 Dec 2021 15:28:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 80FDE3858001 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6C7152114E for ; Tue, 14 Dec 2021 15:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1639495688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HBe9+pceKE3cgw217gcdGbHrqGkPzygVibWUp2eO52w=; b=G+xcrxilRyh+JlkTetEfGESjgQAyH1Kw0zhP6YBncl5YDe59J/ZIHKXlWu72PeiAfUbmmk Ks/IbTUtdvPoFGAqFKj0j+ERRuC7TIEojN3bAhbA4gzLo7oGtNz1XPYasBcnnVmQYIg/JB ZGGHruvJz2uGUc7FnmRLBXlZINpd5EM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1639495688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HBe9+pceKE3cgw217gcdGbHrqGkPzygVibWUp2eO52w=; b=zoPh5CKvsJCeeI3cdri2h6VJQJH8TZ3oRtAewwtB7uCba7xEr6stEItakBcPGLWiK8AOrw 4UPvAXe3gRX176AQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5CB6A13EB3 for ; Tue, 14 Dec 2021 15:28:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gh2xFQi4uGFVZAAAMHmgww (envelope-from ) for ; Tue, 14 Dec 2021 15:28:08 +0000 Message-ID: Date: Tue, 14 Dec 2021 16:28:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] testsuite: fix ASAN errors in i386.exp tests To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The patch fixes various tests in i386.exp that fail with: make check -k RUNTESTFLAGS="i386.exp --target_board=unix/-fsanitize=address" Survives i386.exp w/o sanitizer. Ready for master? Thanks, Martin gcc/testsuite/ChangeLog: * gcc.target/i386/avx2-i32gatherpd256-4.c: Fix ASAN errors. * gcc.target/i386/avx2-i32gatherq256-4.c: Likewise. * gcc.target/i386/avx2-i64gatherpd256-4.c: Likewise. * gcc.target/i386/avx2-i64gatherq256-4.c: Likewise. * gcc.target/i386/avx2-vpabsb256-2.c: Likewise. * gcc.target/i386/avx2-vpabsd256-2.c: Likewise. * gcc.target/i386/avx2-vpabsw256-2.c: Likewise. * gcc.target/i386/avx256-unaligned-load-7.c: Likewise. * gcc.target/i386/avx256-unaligned-store-7.c: Likewise. * gcc.target/i386/pr64291-1.c: Likewise. --- .../gcc.target/i386/avx2-i32gatherpd256-4.c | 14 +++++++++----- .../gcc.target/i386/avx2-i32gatherq256-4.c | 14 +++++++++----- .../gcc.target/i386/avx2-i64gatherpd256-4.c | 14 +++++++++----- .../gcc.target/i386/avx2-i64gatherq256-4.c | 14 +++++++++----- gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c | 2 +- gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c | 2 +- gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c | 2 +- .../gcc.target/i386/avx256-unaligned-load-7.c | 8 ++++---- .../gcc.target/i386/avx256-unaligned-store-7.c | 4 ++-- gcc/testsuite/gcc.target/i386/pr64291-1.c | 2 +- 10 files changed, 46 insertions(+), 30 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c index f24acbd7fe1..17b0c40e4d4 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c +++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c @@ -25,15 +25,19 @@ avx2_test (void) int i; union128i_d idx; union256d res, src, mask; - double s1[4], res_ref[4] = { 0 }; + double s1[16], res_ref[4] = { 0 }; + double *s1_ptr = s1 + 8; - for (i = 0; i < 4; ++i) + for (i = 0; i < ARRAY_SIZE (s1); i++) { /* Set some stuff */ s1[i] = 2.718281828459045 * (i + 1) * (i + 2); + } + for (i = 0; i < 4; ++i) + { /* Set src as something different from s1 */ - src.a[i] = -s1[i]; + src.a[i] = -s1_ptr[i]; /* Mask out evens */ ((long long *) mask.a)[i] = i % 2 ? 0 : -1; @@ -43,9 +47,9 @@ avx2_test (void) idx.a[i] = (16 - (i + 1) * 8) >> 1; } - res.x = _mm256_mask_i32gather_pd (src.x, s1, idx.x, mask.x, 2); + res.x = _mm256_mask_i32gather_pd (src.x, s1_ptr, idx.x, mask.x, 2); - compute_i32gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref); + compute_i32gatherpd256 (src.a, s1_ptr, idx.a, mask.a, 2, res_ref); if (check_union256d (res, res_ref) != 0) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c index 3eab9be5c96..77ebf1fc198 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c +++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c @@ -25,15 +25,19 @@ avx2_test (void) long long i; union128i_d idx; union256i_q res, src, mask; - long long s1[4], res_ref[4] = { 0 }; + long long s1[16], res_ref[4] = { 0 }; + long long *s1_ptr = s1 + 8; - for (i = 0; i < 4; ++i) + for (i = 0; i < ARRAY_SIZE (s1); i++) { /* Set some stuff */ s1[i] = 1983 * (i + 1) * (i + 2); + } + for (i = 0; i < 4; ++i) + { /* Set src as something different from s1 */ - src.a[i] = -s1[i]; + src.a[i] = -s1_ptr[i]; /* Mask out evens */ mask.a[i] = i % 2 ? 0 : -1; @@ -44,10 +48,10 @@ avx2_test (void) } res.x = _mm256_mask_i32gather_epi64 (src.x, - (long long int *) s1, + (long long int *) s1_ptr, idx.x, mask.x, 2); - compute_i32gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref); + compute_i32gatherpd256 (src.a, s1_ptr, idx.a, mask.a, 2, res_ref); if (check_union256i_q (res, res_ref) != 0) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c index 09a5f8a14e0..cf94256e1da 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c +++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c @@ -25,15 +25,19 @@ avx2_test (void) int i; union256i_q idx; union256d res, src, mask; - double s1[4], res_ref[4] = { 0 }; + double s1[16], res_ref[4] = { 0 }; + double *s1_ptr = s1 + 8; - for (i = 0; i < 4; ++i) + for (i = 0; i < ARRAY_SIZE (s1); i++) { /* Set some stuff */ s1[i] = 2.718281828459045 * (i + 1) * (i + 2); + } + for (i = 0; i < 4; ++i) + { /* Set src as something different from s1 */ - src.a[i] = -s1[i]; + src.a[i] = -s1_ptr[i]; /* Mask out evens */ ((long long *) mask.a)[i] = i % 2 ? 0 : -1; @@ -43,9 +47,9 @@ avx2_test (void) idx.a[i] = (16 - (i + 1) * 8) >> 1; } - res.x = _mm256_mask_i64gather_pd (src.x, s1, idx.x, mask.x, 2); + res.x = _mm256_mask_i64gather_pd (src.x, s1_ptr, idx.x, mask.x, 2); - compute_i64gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref); + compute_i64gatherpd256 (src.a, s1_ptr, idx.a, mask.a, 2, res_ref); if (check_union256d (res, res_ref) != 0) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c index 355c8c2b062..396ffb45961 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c +++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c @@ -26,15 +26,19 @@ avx2_test (void) long long i; union256i_q idx; union256i_q res, src, mask; - long long s1[4], res_ref[4] = { 0 }; + long long s1[16], res_ref[4] = { 0 }; + long long *s1_ptr = s1 + 8; - for (i = 0; i < 4; ++i) + for (i = 0; i < ARRAY_SIZE (s1); i++) { /* Set some stuff */ s1[i] = 1983 * (i + 1) * (i + 2); + } + for (i = 0; i < 4; ++i) + { /* Set src as something different from s1 */ - src.a[i] = -s1[i]; + src.a[i] = -s1_ptr[i]; /* Mask out evens */ ((long long *) mask.a)[i] = i % 2 ? 0 : -1; @@ -45,10 +49,10 @@ avx2_test (void) } res.x = _mm256_mask_i64gather_epi64 (src.x, - (long long int *) s1, + (long long int *) s1_ptr, idx.x, mask.x, 2); - compute_i64gatherq256 (src.a, s1, idx.a, mask.a, 2, res_ref); + compute_i64gatherq256 (src.a, s1_ptr, idx.a, mask.a, 2, res_ref); if (check_union256i_q (res, res_ref) != 0) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c index 05db8a40723..9b732af50c8 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c +++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c @@ -28,7 +28,7 @@ avx2_test (void) union256i_b s, d; - for (i = 0; i < 256; ++i) + for (i = 0; i < 256 - 7; ++i) { /* Recompute the results for 256-bits */ compute_pabs256 (&vals[i], ck); diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c index 4c88024b58a..caf1a580674 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c +++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c @@ -27,7 +27,7 @@ avx2_test (void) union256i_d s, d; - for (i = 0; i < 256; ++i) + for (i = 0; i < 256 - 7; ++i) { /* Recompute the results for 256-bits */ compute_pabs256 (&vals[i], ck); diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c index fa4efd2984b..299323de3d6 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c +++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c @@ -28,7 +28,7 @@ avx2_test (void) union256i_w s, d; - for (i = 0; i < 256; ++i) + for (i = 0; i < 256 - 7; ++i) { /* Using only first 2 bytes of int */ /* Recompute the results for 256-bits */ diff --git a/gcc/testsuite/gcc.target/i386/avx256-unaligned-load-7.c b/gcc/testsuite/gcc.target/i386/avx256-unaligned-load-7.c index 4c6054c0ff6..de30ddba348 100644 --- a/gcc/testsuite/gcc.target/i386/avx256-unaligned-load-7.c +++ b/gcc/testsuite/gcc.target/i386/avx256-unaligned-load-7.c @@ -16,10 +16,10 @@ __attribute__ ((noinline)) void foo (void) { - mp = (char **) malloc (N); - lp = (char **) malloc (N); - ep = (char **) malloc (N); - fp = (char **) malloc (N); + mp = (char **) malloc (N * sizeof (char **)); + lp = (char **) malloc (N * sizeof (char **)); + ep = (char **) malloc (N * sizeof (char **)); + fp = (char **) malloc (N * sizeof (char **)); } void diff --git a/gcc/testsuite/gcc.target/i386/avx256-unaligned-store-7.c b/gcc/testsuite/gcc.target/i386/avx256-unaligned-store-7.c index 99a0c719753..2752e7fbec1 100644 --- a/gcc/testsuite/gcc.target/i386/avx256-unaligned-store-7.c +++ b/gcc/testsuite/gcc.target/i386/avx256-unaligned-store-7.c @@ -14,8 +14,8 @@ __attribute__ ((noinline)) void foo (void) { - ep = (char **) malloc (N); - fp = (char **) malloc (N); + ep = (char **) malloc (N * sizeof (char **)); + fp = (char **) malloc (N * sizeof (char **)); } void diff --git a/gcc/testsuite/gcc.target/i386/pr64291-1.c b/gcc/testsuite/gcc.target/i386/pr64291-1.c index 1d3a3809242..85f1e04e724 100644 --- a/gcc/testsuite/gcc.target/i386/pr64291-1.c +++ b/gcc/testsuite/gcc.target/i386/pr64291-1.c @@ -24,7 +24,7 @@ int main () f (n); h (d); qp = (unsigned long*)__builtin_alloca(4099*8) + 1; - dnp = (unsigned long*)__builtin_alloca (2049*8); + dnp = (unsigned long*)__builtin_alloca (2049*8) + 1; alloc = 1; for (test = 0; test < 1; test++) {