From patchwork Thu Jan 2 20:26:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1217145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516587-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mFEQZjvu"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="it0LOzWm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47pfj85swMz9sQp for ; Fri, 3 Jan 2020 07:27:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=PJzkYxsc3jcHb7WurFVehV2vo2xs4UxVK2cWtc+iLYHvIk yzY/GKXMoNUpRYTFNgeJsWHXzGX93rpRO0rOarjaZ/0x5QT7x1GNLYymlj+Iap8R eukj5HAA7vfuFCemEmsOgyTduc3fTFRxFE71WISQyIuJKK4WxPAicrc42zgtE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=UxvY6YZbBuM/eRI1kvsf8xezK3I=; b=mFEQZjvuwUb4zQgrT/Yg ZrXJh6Z6cuYiXDDx0PtmWGKWt2DOdCrrwIdx2t4CRZLSVq+9xCJVORH/S9OCOpP4 AWemnkkUhobrW6w+sAYOwHvEp8XBkbRPCMVHvG/Sh784le5h+XporhZPrJKfukAG Vuxo/jbb9NJknFk5POmDgSo= Received: (qmail 126965 invoked by alias); 2 Jan 2020 20:27:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 126957 invoked by uid 89); 2 Jan 2020 20:27:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=fct, HX-HELO:sk:mail-vs X-HELO: mail-vs1-f52.google.com Received: from mail-vs1-f52.google.com (HELO mail-vs1-f52.google.com) (209.85.217.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Jan 2020 20:27:12 +0000 Received: by mail-vs1-f52.google.com with SMTP id y125so15596722vsb.6 for ; Thu, 02 Jan 2020 12:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=MOhmz24UXnUCqTB91LMT9jIbDLZVTr7uaBdCvO7WygY=; b=it0LOzWmzQHQEJOWG6J4QCq07K54fMriQBwpVLqlJj8IjwLLPqs36SIYBKwEDAEzzQ avJ1EnXKWUwVgSzOcUQh1dDj79a+eJQK+iiu5JrG9ljTRO9OoyYw4guAHOBVo4jyY4CL 8QkMcB9eMxa+zBaLOAcMYNzqNhLSDRMdwdY4Bk14oPsWJSK13FxYF4NQ6XyOI6HsvBYj rKpB7mZXAHQ7kuQA2Yj3xXmvd8kfN1rW2t00DsuJc+cQUaKBgLxiem7ouyKMgrjGkWcQ ur5tpKrSuWnV1ibp4kZ9z60BT5FbCHJ9LOREtGiYyoxEbHcZpuq02rCouyaTEN0OlSBT BvpQ== MIME-Version: 1.0 From: Andrew Pinski Date: Thu, 2 Jan 2020 12:26:59 -0800 Message-ID: Subject: [Committed] Add two testcases for 1bit bit-field To: GCC Patches X-IsSubscribed: yes Hi, While working an optimization, the optimization would produce wrong code but I noticed there was no testcase for that case at all. Committed as obvious. Thanks, Andrew Pinski ChangeLog: * gcc.c-torture/execute/bitfld-8.c: New testcase. * gcc.c-torture/execute/bitfld-9.c: New testcase. Index: gcc.c-torture/execute/bitfld-8.c =================================================================== --- gcc.c-torture/execute/bitfld-8.c (nonexistent) +++ gcc.c-torture/execute/bitfld-8.c (working copy) @@ -0,0 +1,63 @@ +struct mouse_button_str { + unsigned char left : 1; + unsigned char right : 1; + unsigned char middle : 1; + } button; + +static char fct (struct mouse_button_str newbutton) __attribute__ ((__noipa__)); +static char +fct (struct mouse_button_str newbutton) +{ + char l = newbutton.left; + char r = newbutton.right; + char m = newbutton.middle; + return l || r || m; +} + +int main(void) +{ + struct mouse_button_str newbutton1; + newbutton1.left = 1; + newbutton1.middle = 1; + newbutton1.right = 1; + if (!fct (newbutton1)) + __builtin_abort (); + + newbutton1.left = 0; + newbutton1.middle = 1; + newbutton1.right = 1; + if (!fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 1; + newbutton1.middle = 0; + newbutton1.right = 1; + if (!fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 1; + newbutton1.middle = 1; + newbutton1.right = 0; + if (!fct (newbutton1)) + __builtin_abort (); + + + newbutton1.left = 1; + newbutton1.middle = 0; + newbutton1.right = 0; + if (!fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 0; + newbutton1.middle = 1; + newbutton1.right = 0; + if (!fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 0; + newbutton1.middle = 0; + newbutton1.right = 1; + if (!fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 0; + newbutton1.middle = 0; + newbutton1.right = 0; + if (fct (newbutton1)) + __builtin_abort (); +} \ No newline at end of file Index: gcc.c-torture/execute/bitfld-9.c =================================================================== --- gcc.c-torture/execute/bitfld-9.c (nonexistent) +++ gcc.c-torture/execute/bitfld-9.c (working copy) @@ -0,0 +1,63 @@ +struct mouse_button_str { + unsigned char left : 1; + unsigned char right : 1; + unsigned char middle : 1; + } button; + +static char fct (struct mouse_button_str newbutton) __attribute__ ((__noipa__)); +static char +fct (struct mouse_button_str newbutton) +{ + char l = newbutton.left; + char r = newbutton.right; + char m = newbutton.middle; + return l && r && m; +} + +int main(void) +{ + struct mouse_button_str newbutton1; + newbutton1.left = 1; + newbutton1.middle = 1; + newbutton1.right = 1; + if (!fct (newbutton1)) + __builtin_abort (); + + newbutton1.left = 0; + newbutton1.middle = 1; + newbutton1.right = 1; + if (fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 1; + newbutton1.middle = 0; + newbutton1.right = 1; + if (fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 1; + newbutton1.middle = 1; + newbutton1.right = 0; + if (fct (newbutton1)) + __builtin_abort (); + + + newbutton1.left = 1; + newbutton1.middle = 0; + newbutton1.right = 0; + if (fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 0; + newbutton1.middle = 1; + newbutton1.right = 0; + if (fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 0; + newbutton1.middle = 0; + newbutton1.right = 1; + if (fct (newbutton1)) + __builtin_abort (); + newbutton1.left = 0; + newbutton1.middle = 0; + newbutton1.right = 0; + if (fct (newbutton1)) + __builtin_abort (); +}