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 DD0BF38582AD for ; Wed, 19 Oct 2022 14:02:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DD0BF38582AD 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=1666188150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m5DF2F8azQhkfjzzbAcSfAUOFvzUUOqupxnRAFtBigc=; b=D2nFhiff9+sJRkR0XMRZTOMYAscSkvvrelM/geSxqKwr2wZuKXoNHNxXLgiFKXo3X+eF57 zOSoHT4LHFumYvI5xLHKthDcearjtDSZZ/eJV5u4gYwMMLx1QnKFa4BP8KnK/EAJt77Beo z2ZDevkCHoYmgaraypThHP7KTrKaTvQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-452-hoRNQrCVPLOfgUl0Waw95A-1; Wed, 19 Oct 2022 10:02:27 -0400 X-MC-Unique: hoRNQrCVPLOfgUl0Waw95A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FBE2833B00 for ; Wed, 19 Oct 2022 14:02:26 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 240B34048D84; Wed, 19 Oct 2022 14:02:19 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 29JE2GY8044814 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 16:02:16 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29JE2GLM044813; Wed, 19 Oct 2022 16:02:16 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [PR tree-optimization/107312] Make range_true_and_false work with 1-bit signed types. Date: Wed, 19 Oct 2022 16:02:12 +0200 Message-Id: <20221019140212.44796-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 List-Id: range_true_and_false() returns a range of [0,1], which for a 1-bit signed integer gets passed to the irange setter as [0, -1]. These endpoints are out of order and cause an ICE. Through some dumb luck, the legacy code swaps out of order endpoints, because old VRP would sometimes pass endpoints reversed, depending on the setter to fix them. This swapping does not happen for non-legacy, hence the ICE. The right thing to do (apart from killing legacy and 1-bit signed integers ;-)), is to avoid passing out of order endpoints for 1-bit signed integers. For that matter, a range of [-1, 0] (signed) or [0, 1] (unsigned) is just varying. PR tree-optimization/107312 gcc/ChangeLog: * range.h (range_true_and_false): Special case 1-bit signed types. * value-range.cc (range_tests_misc): New test. gcc/testsuite/ChangeLog: * gcc.target/i386/pr107312.c: New test. --- gcc/range.h | 2 ++ gcc/testsuite/gcc.target/i386/pr107312.c | 11 +++++++++++ gcc/value-range.cc | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr107312.c diff --git a/gcc/range.h b/gcc/range.h index 8138d6f5515..ba3a6b2516f 100644 --- a/gcc/range.h +++ b/gcc/range.h @@ -50,6 +50,8 @@ static inline int_range<1> range_true_and_false (tree type) { unsigned prec = TYPE_PRECISION (type); + if (prec == 1) + return int_range<2> (type); return int_range<2> (type, wi::zero (prec), wi::one (prec)); } diff --git a/gcc/testsuite/gcc.target/i386/pr107312.c b/gcc/testsuite/gcc.target/i386/pr107312.c new file mode 100644 index 00000000000..b4180e3bd7d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr107312.c @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-mavx512vbmi -O1 -ftree-loop-vectorize" } + +void +foo (_Float16 *r, short int *a) +{ + int i; + + for (i = 0; i < 32; ++i) + r[i] = !!a[i]; +} diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 90d5e660684..511cd0ad767 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -3437,6 +3437,8 @@ range_tests_misc () max.union_ (min); ASSERT_TRUE (max.varying_p ()); } + // Test that we can set a range of true+false for a 1-bit signed int. + r0 = range_true_and_false (one_bit_type); // Test inversion of 1-bit signed integers. { -- 2.37.3