From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 3D9E83858D35 for ; Thu, 29 Jun 2023 12:24:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D9E83858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6644721854; Thu, 29 Jun 2023 12:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688041454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=irskwWtJQundZqkdYlI2rSCDwDQgOqEYPDwFrVvh/kI=; b=pxdg8EkM6fg2ltvEvqNB6cfZOXLfJUJ7+vitsJZ2wJ/64xrTziGyiRSJu51vGlYUxUP1pf LIdyFddvDZatoZkuUE5eicDaMSQ16xJ5MGL1H54e6PUAc6/fKJGSGZSaWR1SeVCjhx7tbZ u5iQ4NBJA2UTOvJIouZChrOX1LN1N0I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688041454; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=irskwWtJQundZqkdYlI2rSCDwDQgOqEYPDwFrVvh/kI=; b=EYQcbXqu+yD/JB9zjCFw3SW5L8AZy1njx8mRTf1XSv9b0fttHetHMO9YqdeCL6Cy5mR3Nx MgbFjJcNtxBIo7Bg== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 591A92C141; Thu, 29 Jun 2023 12:24:14 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 10510) id 4F0F467ED; Thu, 29 Jun 2023 12:24:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by wotan.suse.de (Postfix) with ESMTP id 4C28967D6; Thu, 29 Jun 2023 12:24:14 +0000 (UTC) Date: Thu, 29 Jun 2023 12:24:13 +0000 (UTC) From: Michael Matz To: Krister Walfridsson cc: Richard Biener , gcc@gcc.gnu.org Subject: Re: types in GIMPLE IR In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: Hello, On Thu, 29 Jun 2023, Krister Walfridsson wrote: > > The thing with signed bools is that the two relevant values are -1 (true) > > and 0 (false), those are used for vector bool components where we also > > need them to be of wider type (32bits in this case). > > My main confusion comes from seeing IR doing arithmetic such as > > _127; > _169; > ... > _169 = _127 + -1; > > or > > _127; > _169; > ... > _169 = -_127; > > and it was unclear to me what kind of arithmetic is allowed. > > I have now verified that all cases seems to be just one operation of this form > (where _127 has the value 0 or 1), so it cannot construct values such as 42. > But the wide signed Boolean can have the three different values 1, 0, and -1, > which I still think is at least one too many. :) It definitely is. For signed bool it should be -1 and 0, for unsigned bool 1 and 0. And of course, arithmetic on bools is always dubious, that should all be logical operations. Modulo-arithmetic (mod 2) could be made to work, but then we would have to give up the idea of signed bools and always use conversions to signed int to get a bitmaks of all-ones. And as mod-2-arithmetic is equivalent to logical ops it seems a bit futile to go that way. Of course, enforcing this all might lead to a surprising heap of errors, but one has to start somewhere, so ... > I'll update my tool to complain if the value is outside the range [-1, > 1]. ... maybe not do that, at least optionally, that maybe somewhen someone can look into fixing that all up? :-) -fdubious-bools? Ciao, Michael.