From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id CBC353858D1E for ; Mon, 24 Apr 2023 15:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBC353858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682351652; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=x28XBuGCUUiKvM5VKse5X8KvHwgeWPyf19sX57DQXRs=; b=LdAvSfvCCdJAt9YPCH8+w7YzYEjtxyAHLlv3MiSGtfCkhZYmnOOI6JSzzkuaYUUwiYuVam lXp1N231Odm7KT40Twsl/n5L2DF1x026jbOaa8LcgkSSxMIo10ZnVjqKv9ccVOgXUe9JHG UZCfsxcz6FwuZT3T+GeoDJn9HIJzVUo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-78-iy2LqOAiOny7Ar_Qy90hvA-1; Mon, 24 Apr 2023 11:54:09 -0400 X-MC-Unique: iy2LqOAiOny7Ar_Qy90hvA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8D811C0A584; Mon, 24 Apr 2023 15:54:08 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6443B492C13; Mon, 24 Apr 2023 15:54:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 33OFs4HJ2356036 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 17:54:04 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33OFs3Qs2356035; Mon, 24 Apr 2023 17:54:03 +0200 Date: Mon, 24 Apr 2023 17:54:02 +0200 From: Jakub Jelinek To: David Edelsohn , Segher Boessenkool , Kewen Lin Cc: gcc-patches@gcc.gnu.org, Xionghu Luo Subject: [PATCH] powerpc: Fix up *branch_anddi3_dot for -m32 -mpowerpc64 [PR109566] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! The following testcase reduced from newlib ICEs on powerpc-linux, with -O2 -m32 -mpowerpc64 since r12-6433 PR102239 optimization was added and on the original testcase since some ranger improvements in GCC 13 made it no longer latent on newlib. The problem is that the *branch_anddi3_dot define_insn_and_split relies on the *rotldi3_mask_dot define_insn_and_split being recognized during splitting. The rs6000_is_valid_rotate_dot_mask function checks whether the mask is a CONST_INT which is a valid mask, but *rotl3_mask_dot in addition to checking that it is a valid mask also has (mode == Pmode || UINTVAL (operands[3]) <= 0x7fffffff) test in the condition. For TARGET_64BIT that doesn't add any further requirements, but for !TARGET_64BIT && TARGET_POWERPC64 if the AND second operand is larger than INT_MAX it will not be recognized. The rs6000_is_valid_rotate_dot_mask function is used solely in one spot, condition of *branch_anddi3_dot, so the following patch adjusts it to check for that as well. Bootstrapped/regtested on powerpc64-linux (-m32/-m64) and powerpc64le-linux, ok for trunk/13.1/12.3? 2023-04-24 Jakub Jelinek PR target/109566 * config/rs6000/rs6000.cc (rs6000_is_valid_rotate_dot_mask): For !TARGET_64BIT, don't return true if UINTVAL (mask) << (63 - nb) is larger than signed int maximum. * gcc.target/powerpc/pr109566.c: New test. --- gcc/config/rs6000/rs6000.cc.jj 2023-04-04 10:33:47.433201866 +0200 +++ gcc/config/rs6000/rs6000.cc 2023-04-24 12:31:07.237031550 +0200 @@ -11409,7 +11409,16 @@ bool rs6000_is_valid_rotate_dot_mask (rtx mask, machine_mode mode) { int nb, ne; - return rs6000_is_valid_mask (mask, &nb, &ne, mode) && nb >= ne && ne > 0; + if (rs6000_is_valid_mask (mask, &nb, &ne, mode) && nb >= ne && ne > 0) + { + if (TARGET_64BIT) + return true; + /* *rotldi3_mask_dot requires for -m32 -mpowerpc64 that the mask is + <= 0x7ffffff. */ + return (UINTVAL (mask) << (63 - nb)) <= 0x7fffffff; + } + else + return false; } /* Return whether MASK (a CONST_INT) is a valid mask for any rlwinm, rldicl, --- gcc/testsuite/gcc.target/powerpc/pr109566.c.jj 2023-04-24 12:54:48.293266468 +0200 +++ gcc/testsuite/gcc.target/powerpc/pr109566.c 2023-04-24 12:34:34.306006418 +0200 @@ -0,0 +1,15 @@ +/* PR target/109566 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mpowerpc64" } */ + +void +foo (double x) +{ + union { double d; unsigned i; } u; + u.d = x; + if (u.i & 0x7ff00000) + return; + else + for (;;) + ; +} Jakub