From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from franke.ms (serveronline.org [136.243.37.185]) by sourceware.org (Postfix) with ESMTPS id B07DE3858D20 for ; Wed, 10 Apr 2024 08:58:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B07DE3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=franke.ms Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=franke.ms ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B07DE3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=136.243.37.185 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712739484; cv=none; b=Xekol/iFnzh+iglJ6j635s7OUw7DyIUFRWcV7rzDQ2FXr78EteUNJnSsV+aEt2tKX6rqB6X5sHLO/2mu/btKVMrrZ6cyl3aaUWblGyHLmbKZxSWxw/XT54w/olQKdZoO1ONEEUxOzI4iib9HYSp8c3Ajk4Hqd6AQEovYvTApHKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712739484; c=relaxed/simple; bh=gAdYlL6WCT+8HRFn5FzEp6fwEBzr75gFdhEPnwcsPOY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=EgZDE2BRCqsxzVuoZ7NCjUoKyZSXgoJFWCZMQ3Zv3gQnVWyuiqun/zTRGXFMOpOSNI95M+q0b5BwnNDTZgXDwx9KrNQ5GJ6dFbQIGU2fi0E7HyhnwdDndQYxfcGOPojylvJ1uZCIfpAmZ6PaOLk3YK/dYR39jdKNOfXvmIiJDDI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from HP (i59F6C2ED.versanet.de [89.246.194.237]) by serveronline.org (BEJY V1.6.12-SNAPSHOT (c) 2000-2021 by BebboSoft, Stefan "Bebbo" Franke, all rights reserved) with SMTP id 18ec7359d6f170fa174f1c46ae7 from stefan@franke.ms for gcc-help@gcc.gnu.org; Wed, 10 Apr 2024 09:52:43 +0100 From: To: Subject: optimizer discards sign information Date: Wed, 10 Apr 2024 10:52:42 +0200 Message-ID: <016501da8b24$735d5170$5a17f450$@franke.ms> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdqLI4kF3QPyIhXURMKwgjFcQ0j+Cw== Content-Language: de X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,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: Hi all, I just stumbled over an issue, which is present in almost all gcc = versions. I worked around using inline assembly=85 Maybe gcc behaves correct and I am wrong? Here is the code: https://godbolt.org/z/cW8jcdh56 typedef unsigned long long int u64; typedef unsigned int u32; typedef unsigned short u16; u64 foo(u16 a, u16 b) { =A0 =A0 u32 x =3D a * b; =A0 =A0 u64 r =3D x; =A0 =A0 return r; } And on gcc 13.2 x86.64 you get foo: =A0 =A0 =A0 =A0 movzx =A0 esi, si =A0 =A0 =A0 =A0 movzx =A0 edi, di =A0 =A0 =A0 =A0 imul =A0 =A0edi, esi =A0 =A0 =A0 =A0 movsx =A0 rax, edi =A0 =A0 =A0 =A0 ret There is a sign extension! The optimizer step discards the information =A0x_6 =3D (u32) _3; and uses _3 directly instead, which is signed. Am I wrong or is it gcc? Since this is a tree pass, all targets are affected. And it=92s already present in gcc-6.5 Best regards Stefan=20