From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 2E96638B5897 for ; Tue, 4 Jun 2024 14:27:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E96638B5897 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2E96638B5897 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::331 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717511270; cv=none; b=fJBh4HTIydQF0OBQIQs7YB7vazKaniLvkwIoIdHYe/N2VqbYE9LYQZPsfI1cjLp6aWZJmrrqovdYozcwoU7bI85pSP0jy3UedEyzKwsHmg1Dtr6a1QsqCc+OTL/E8ibGO519xDM3fys+AlBFAeMvEfUVWnSsx1e4oZfegJdfEtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717511270; c=relaxed/simple; bh=kb+Ksgxy+j7a3YUX83J0nvpkn0n6R028dJlUw3AdV4Q=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=uSgg+6lyb9+Potbhnc0LlVGD29C/6lerSexQkakWII4XEzzWUuhq/WHGBLae7SYa/26ZszqOOHaPsYRbf/WdFxQR3Rg009TygB3Rveo61AFTgY4u0WyGLGEZf//5CN8H8SpEAaWC5yvCfOsotmULrcW0lBFi3JOBtGJ3KCENJ/o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42120e3911eso52131655e9.0 for ; Tue, 04 Jun 2024 07:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717511267; x=1718116067; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Bm3BGuEr7MEzuU2Q8vpuIfYrRmTHVqFEVboY4OD1+hs=; b=HZ9/dJeoZ6a/ILM8NG7h7QS9bvNkVU7foepkM94uOshzFvp33b5tTMe9DJujf4Lx8o LcifSLS8dX8zaTZtVekzZoJjwg5haHSZ9xnl6zjGDVYKexJ718z8YlstQFalnGctiT9r GLK476quThApsYdd6YtsIRra5lxWjoxtyJ+zwMcv65/No/DiJ1bAO25o3+q20QBWHgPf G37aozUpNzwKIsf2M/xkddAdNukw7M9e0388WhNxLb+mJBttIGy7gr/oRBVp/Z4piE82 x4TuY1BERUkq7vZUwbbrU05galSNENakk4gQhGLbrtBit4jSlmZ9WfPxf9JzUpAIU/mG P83g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717511267; x=1718116067; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bm3BGuEr7MEzuU2Q8vpuIfYrRmTHVqFEVboY4OD1+hs=; b=t3OgB9sPeshOtJUNb4ACvluOJBEnlgEXacdhSK6fbi/rlbXtp47f0fW5Te1ZRZxGRK koHjX7LjiKGx7rrV8b58xGRIvFvGD1WdZwURH595T4siukSDz/Q+Jj7+68K7r9CZPLtU OBKpX/ZULYNbAdwAAXaYlZewYMdga3JbqNf2AQL3eEq/chRlb9KgLJLgqTkqo6MhcOf4 w8lTNwXC00VtcBvJBeEe28anoeFcAeQFWYwDGh3oEHRYPnBE8UeZJk9BxjiqA4qTMJNo cCzxeh0mB0ywI9s7rVYK+DWkKXRvDq+Z3zZTvSqiueq1/cLPnPj/o1PpNq9NRDcxP6Zu 2/IQ== X-Forwarded-Encrypted: i=1; AJvYcCUaUNAEOgsSOVKTfOABATiQ2KjNDZYQywpOBXE9RFYjZ9wHx0YznpprwqyTGX8C4IPZ9BwaTeuAjwV4c4Oi6GzNeM/QvvY7ow== X-Gm-Message-State: AOJu0YwX7UT7yNfSUP8Nn49bOMbrwH7KlZN1NpVSyFmPR4H4CAAFrIMq fLbBljktD1EKH+5LY5BvVkvtRvA7eRyRAnHrJDY+UZLUESB+YjJB X-Google-Smtp-Source: AGHT+IGEUbxOzrI9bqrXMA57b1r/9jtklpcogkkXqrzTwUA4mISF+1XBDS8l5q2iAfqLenQ84n54Eg== X-Received: by 2002:a05:600c:3584:b0:41f:e7ac:cc72 with SMTP id 5b1f17b1804b1-4212e0c408dmr97383415e9.40.1717511266640; Tue, 04 Jun 2024 07:27:46 -0700 (PDT) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214a4abdd5sm17207995e9.0.2024.06.04.07.27.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jun 2024 07:27:46 -0700 (PDT) Message-ID: Date: Tue, 4 Jun 2024 08:27:41 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH] Don't simplify NAN/INF or out-of-range constant for FIX/UNSIGNED_FIX. Content-Language: en-US To: liuhongt , gcc-patches@gcc.gnu.org Cc: jakub@redhat.com References: <20240527010803.2851191-1-hongtao.liu@intel.com> From: Jeff Law In-Reply-To: <20240527010803.2851191-1-hongtao.liu@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On 5/26/24 7:08 PM, liuhongt wrote: > Update in V2: > Guard constant folding for overflow value in > fold_convert_const_int_from_real with flag_trapping_math. > Add -fno-trapping-math to related testcases which warn for overflow > in conversion from floating point to integer. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? > > According to IEEE standard, for conversions from floating point to > integer. When a NaN or infinite operand cannot be represented in the > destination format and this cannot otherwise be indicated, the invalid > operation exception shall be signaled. When a numeric operand would > convert to an integer outside the range of the destination format, the > invalid operation exception shall be signaled if this situation cannot > otherwise be indicated. > > The patch prevent simplication of the conversion from floating point > to integer for NAN/INF/out-of-range constant when flag_trapping_math. > > gcc/ChangeLog: > > PR rtl-optimization/100927 > PR rtl-optimization/115161 > PR rtl-optimization/115115 > * simplify-rtx.cc (simplify_const_unary_operation): Prevent > simplication of FIX/UNSIGNED_FIX for NAN/INF/out-of-range > constant when flag_trapping_math. > * fold-const.cc (fold_convert_const_int_from_real): Don't fold > for overflow value when_trapping_math. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr100927.c: New test. > * c-c++-common/Wconversion-1.c: Add -fno-trapping-math. > * c-c++-common/dfp/convert-int-saturate.c: Ditto. > * g++.dg/ubsan/pr63956.C: Ditto. > * g++.dg/warn/Wconversion-real-integer.C: Ditto. > * gcc.c-torture/execute/20031003-1.c: Ditto. > * gcc.dg/Wconversion-complex-c99.c: Ditto. > * gcc.dg/Wconversion-real-integer.c: Ditto. > * gcc.dg/c90-const-expr-11.c: Ditto. > * gcc.dg/overflow-warn-8.c: Ditto. OK. Thanks. jeff