From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by sourceware.org (Postfix) with ESMTPS id 81EA6385780A for ; Mon, 16 Nov 2020 22:38:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 81EA6385780A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jimw@sifive.com Received: by mail-ed1-x541.google.com with SMTP id cq7so20405238edb.4 for ; Mon, 16 Nov 2020 14:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AqIeSaIBMuacZdCQtwPArnmu4GPueWrFiV8Hu9JxVHM=; b=ZCWZvAIFnI1oI0HWsnY5uX/kvRQIxSW7WZYHXo7H1dqRV/7bBYYezGho32uHM9fesG NtmJYcNMouE/Hr8E+jfg34eecgaSJ+8r1DWF5T/EDT/XTOLuoZUAVJ/6NdbzTzRhVs7i WKjHm4qBJpOHGxhJ/zDa1XLbVKZTeGEte90XTPJ/6tAH5w+WWQcwjRMZW2wDotXjl8ER r4KYSllOSVcij+A4R15UZU11BCZmcLEPovmTRvsyzvnUjfZvRfVIwEiA11yEOtFEvsUr lckTNzDj2h5jma9TCDBHM7z463RhyfbPMeqmyLHRApG7cstq+fcINcIgW2OJE2ZHddSe RlDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AqIeSaIBMuacZdCQtwPArnmu4GPueWrFiV8Hu9JxVHM=; b=uTaVs2PVop0UGazNrTsaDKDZOR5MJhEOWShnHZMHAftY4I3BCKjEA0l5JLBuq+Jtpn 2OYxw5YK5KJKvocVPSJf18pxpxLwixpEZmj0Q0hEhz1o8xbXVOV2Osj3l0o6vwyw7dZN /y6JVcXXB/XyX60lYVeKeWSNSD5XXlFM6A/p71lJY0x7Mu45CXnrY4pEVj4PxKZ4QV7Y 9CqSNWlfQzfbXck1lmDc+DkSxWH/RRsC+YXW1ExHi4y97PUdVcbIqxowk822HClNDPlp SrKOzVZvzruQcT2FY/4auXgFZr5GSybc1HvXk8rY72e7chpTFRC15KgKOJZyEl5U6n/8 mFBw== X-Gm-Message-State: AOAM531txYojFzgnAxoJlqS0OhMTV0SBvUJLmfS9v6c4ffk2jouA/lIb NH0bA0ZeksiF6pUh2CNpoEMjn9qPOAa2R3HhIlHakw== X-Google-Smtp-Source: ABdhPJzV7v7cS3vlDeK8Xfix21HqvuMc6ukvj6koLTmo5sFT0c6erHlub5AmVmrKyTRJzduWeSrJM/Qdm4jyBk9k83I= X-Received: by 2002:aa7:d59a:: with SMTP id r26mr14102480edq.188.1605566312589; Mon, 16 Nov 2020 14:38:32 -0800 (PST) MIME-Version: 1.0 References: <1605553027-5331-1-git-send-email-philipp.tomsich@vrull.eu> In-Reply-To: <1605553027-5331-1-git-send-email-philipp.tomsich@vrull.eu> From: Jim Wilson Date: Mon, 16 Nov 2020 14:38:21 -0800 Message-ID: Subject: Re: [PATCH v1 1/2] Simplify shifts wider than the bitwidth of types To: Philipp Tomsich Cc: GCC Patches , Philipp Tomsich X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 22:38:34 -0000 On Mon, Nov 16, 2020 at 10:57 AM Philipp Tomsich wrote: > This adds simplify_using_ranges::simplify_lshift_using_ranges to > detect and rewrite such cases. If the intersection of meaningful > shift amounts for the underlying type and the value-range computed > for the shift-amount (whether an integer constant or a variable) is > empty, the statement is replaced with the zero-constant of the same > precision as the result. > This has the risk of breaking some user code. I've seen people write code for RISC-V knowing that the hardware truncates shift counts, and so not doing the full calculation to get the right value but just letting the compiler/hardware calculate it for them via truncation. Of course this code has implemented defined result, but there is no reason to break it unnecessarily. Jim