From patchwork Fri Sep 23 09:24:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp123145wrt; Fri, 23 Sep 2022 02:26:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dTu2sfTQbIOnQWokxw8pB+bEASmtpdMwiCuVmZOkgGSkG2jaubwhJSVLjXm0f3i8t4xD4 X-Received: by 2002:a17:907:9616:b0:782:4a87:3aaf with SMTP id gb22-20020a170907961600b007824a873aafmr6063434ejc.131.1663925173794; Fri, 23 Sep 2022 02:26:13 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qf28-20020a1709077f1c00b0073056870528si8632114ejc.888.2022.09.23.02.26.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 02:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jKF+u8d6; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E6A653857006 for ; Fri, 23 Sep 2022 09:26:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6A653857006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663925163; bh=mSwCke9E9C5Wf4OnaPXTtOdMhsP5SWl/yWgJagsNBHU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jKF+u8d6SSzCqUgBCKX9blCejJaLBX90h4+MBwX2tE0Zm1Wj5jJwBQkPQV97JUKxk tSSRx+n80fruHu7Py/b9CnGS6r9x7YM+s8L1/84s0e/SIrB0IIuhBxZpTzu9jmJT2Y Lxi24e0RTT6ur37llygm222NCHpuQE+PFleHtMic= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130047.outbound.protection.outlook.com [40.107.13.47]) by sourceware.org (Postfix) with ESMTPS id F17463858C52 for ; Fri, 23 Sep 2022 09:25:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F17463858C52 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Fr58zU30mLVv5E7fNPj9O0jXE8bG4MlzkGTS/L7CaTDDOjd+5cEGrJkzkHopkU5XGM3eaNZI9VPl861VrQNbmHRGawnrs6vMshlPmRHhglQDwQz1ZDQdbC2192W407Hh6ACcKwbJ2Y6QpvmlFoApC3FyitBCG3Ozo94TN+8BPY3eFLvjr2k4W3M6zBkzryXEAGpAXMbJpmGXWGtjkmOi8OHn/+f4Xzbnz33dS7LnfMd2ZNxu02Vy8ZfP85CgkS+nQ2/AUOnrc/6N0SN3Sw5VrWKN21xH5+MwbY46/YkUAwpzluxT7eV5KWTlwOAbzRQnm+p2dhVsPmiUVOFMpWQI6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mSwCke9E9C5Wf4OnaPXTtOdMhsP5SWl/yWgJagsNBHU=; b=Aedq4TM7tTxCQvzi4gJGAjGAJ4FFdo9TetbwT8aT3Opve+01Jl+lepwvXF+7PAGfZVA0+xc4aWe6QX2dentzkSyBf4H7MOrny7VR0BNJLHgfvPbxTmiuFAJpN3JeIw1aZzNphaY8VFrw8ChTJhA51P045SPOj9e7gTG+zxxe5dRJVkc2tJ33sIIjQePEJt/8kJ6OoHC5wGOc1dE+8TkDdybrt8T+5wE98RaeJ6x/ZP8zw0b/qZtgszh/Zz3130szWGEaxlpEVzXmYaJzv5q/awQSPLNvpU+w1w35UcX/4W2xlTGZSGidmF6+ZrRRCrxHosF71eUYtoEUaAD1ssQz7g== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AM6P194CA0078.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::19) by DB8PR08MB5386.eurprd08.prod.outlook.com (2603:10a6:10:f9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.16; Fri, 23 Sep 2022 09:25:13 +0000 Received: from AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::54) by AM6P194CA0078.outlook.office365.com (2603:10a6:209:8f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20 via Frontend Transport; Fri, 23 Sep 2022 09:25:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT035.mail.protection.outlook.com (100.127.141.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Fri, 23 Sep 2022 09:25:12 +0000 Received: ("Tessian outbound 3c27ae03f5ec:v124"); Fri, 23 Sep 2022 09:25:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3f3f52b6993c9019 X-CR-MTA-TID: 64aa7808 Received: from 6540a6fb6139.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 153D05FB-50D1-41B4-9388-9848E61CED32.1; Fri, 23 Sep 2022 09:25:05 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6540a6fb6139.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 23 Sep 2022 09:25:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SXdiD/bFQutREgc4tDhYxUNMCn4O7zLkMW22mLqULy4tZrWjqiacoQdlk3RX4oPl9AAALLFgrTi9udEDaOeA/kMi2CkJklfRQtqyryaxBCiPN6lHeaJCETt694zoXvl8Qsyb4x8tBPn01W8Hd8D26KuABQ/rrSOs9AThr7iwSLARCJOUJdPIZqbiBclqpiJveIaitshvRB0udRAYKM2nGp49QJtx9gEE10G6DZZJRuAK5hGwfrbA76pQzLs5mNOudAm/ROJTrIpLvbyuWZK2eDbs/WIq6rNR8NAyHTznAkAIhCW/dK3m+CkzN8mVneLkEQHvo1qAeHxDGD+1zmBeJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mSwCke9E9C5Wf4OnaPXTtOdMhsP5SWl/yWgJagsNBHU=; b=oMsFmgv4gN6kwsY2M1rYp0RfdV2BY/Bhof5847c1TZ/hyE5QYTYIQcIH08sW2DL1BQ1qppYBr1pgwRLaJRQ26+sZ5WFmSJ/cSCKzz6g8CiHhxe1PQUaqmTL88O4HV3s8NQu4n1y3cDThZrB85oUVofA7PMPDsUJLf1fW7gXd9/53X5jZAkP3VkLAjUR4v8CVYunwWjQ3L1hbGdfcegRjmdSckITyqOkJVrE6wkxuWT1ertQLE09oX7xLyJpPs+JPathrmlyG4b0q23YBH2yI4vKy/1FLZoalrgGSUVf5cCYEVf2NjhDNIH8lRLZZhAzf55KDyod4QKiapuUNB7fGJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by AS2PR08MB9475.eurprd08.prod.outlook.com (2603:10a6:20b:5e8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.16; Fri, 23 Sep 2022 09:25:03 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::6529:66e5:e7d4:1a40]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::6529:66e5:e7d4:1a40%4]) with mapi id 15.20.5632.021; Fri, 23 Sep 2022 09:25:03 +0000 Date: Fri, 23 Sep 2022 10:24:56 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2]middle-end: RFC: On expansion of conditional branches, give hint if argument is a truth type to backend Message-ID: Content-Disposition: inline X-ClientProxiedBy: BN9PR03CA0892.namprd03.prod.outlook.com (2603:10b6:408:13c::27) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|AS2PR08MB9475:EE_|AM7EUR03FT035:EE_|DB8PR08MB5386:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dabb9e7-2080-46dc-2614-08da9d4584a7 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: CdsJnzbxB2pBBtnpPaqSOZ+XjASgPYJl263PR9KnMoEPaXKL0KciDvHMlamvuJfxIYTn+J0LwhkC/+p7xBLU+SsY8cbGfcC4xtdJGm3XDdOqFdQpAtUm+j7Jda5LgFZnxxPZm1WjTfYFsqlM7lhjKLvXH10Dh427ixDTGDLFA64ScB7lkDAilDPC8EjRphzC4VOKXVUVzSl6rhtzMhl8P+FMNHOvY1IBD0DYCj3IQYuVSJl5KCdtWWHzm3TsM9mz4gt8q+WGzUciQwguSjILneK43p/21WXJ24hMif6ka8HNnkiqm6xAcJKQUHUBQ84ZqS0NtlI8ol/jUFmX9j4oWlqSCwz7qW0Kh8pT1QeHNmbDF5m0Sbsxnv2JL/J8Wgwt6DA475fKIq1a7wawuh/T++3sIBfv1da8ynhz71vAQe8Jof+FlD73V/ILdASCojIvq7TFftFuE2TY6zevGvhBqcUfe/QTU6utH+Trv1He1oGGDQxUdeIB6HT4uMbMwLcxYDROeVZ4q9x27G60DeZli829FctKDtGIHxZP1ccdMmwJJlXi4DCwkmSZSJKJWfHB39jngrwKnAVqulK2ApSFuoGxUnRMvao5OQ26EDKtNHs3mhkCvvxwzaAkBupcLLfW/jUxq7GO91R1kinSshgmh5m9e/DClgVgmxJioGa6olPaJT2kI7HniFMo1x5GlWftaKCi0TNh0QtA1HkzeI1hq+O/Hdq4FH2h4O8B7BCNO8kLJ/SwoD4HYbj90K7MUtnTlZfPKLw17Wb/YTcm4Rq37w4dKUWeO9vrRqmsaDV+zrs= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB5325.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(366004)(451199015)(6666004)(2906002)(6506007)(44144004)(33964004)(86362001)(478600001)(6486002)(8936002)(6916009)(41300700001)(36756003)(5660300002)(44832011)(186003)(6512007)(26005)(2616005)(4743002)(38100700002)(235185007)(66899012)(66556008)(4326008)(316002)(66946007)(66476007)(8676002)(83380400001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9475 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 35e7d24b-5191-4973-ca1d-08da9d457eca X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C+srADePXJ1hWgnl83/Fy6Sffa2vnTUBeHy9sEPet/pqulr2UFUjxVimfM+s0z9gG0aMKtaJKzPRpmCq+3a+h0LxoTH4fQtv2JTfLyMmMTjgufMoKiOT/zsCrh+utNhdvYmlXAeTnKXXGAawwXEPNqQS8+n2kjbrAWdKYNIyisR3ppOWWzLyxDReZ0N+nokh7x8qHWcxLeea7YzE5wue9BDBh4FRtk/hz2gQlOzfdDwx/Xe0QemstnjA+z0DeXGzWwgPC7x/nH/8NeFooTKg7BeZClt5BjmJBOGysSbwIY99gJYNnI/V2VJLc0ldtTjkrBoq11AQc/XIrtUjgvUdG19UnSTnspcP9uZ6F3MxgNHA1nmxW6lEsVPIY9DAcnk3jnqs25u33STTDiaYBmZVIhwyOirhR7IFMPkwO1CgzgALUs/IO+CtDAzKA1fnQfTGnmgh4n67Mb4n07E6gc5t04AAvSt3+HCy9POe4dXGcrV9CgUYpo9kZc7zvPhVljF+mO8J8n0NiWeiLhHINkNi8nZk/wmFOKjIy9DU2vKonbx3aNer+JKEp/z0bLOavviHZAKvGkWvVOAsvmgaL2GGEf7C2pM/25lZc71i7LBQom0dV9kLNSEcYqynGntYYFDExDLtDA+QLtlmOjfzY+o4uYa9YDqEPQwsiYTwoKRvKT6RqktKti55WcIAFXvbsfWcwjey+TDvBTOd0sdk9kWxk8jGOBSN6Tebwhnwt8e1UWG9Rv/pY1mLal4SIMyq/nZt+Ac2xnELe+RQu+AU0DvOIjw9Sf0r/qREMQ25nm+8T401W6ynC4H8QgO63aL/AIXe X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199015)(40470700004)(36840700001)(46966006)(81166007)(41300700001)(66899012)(82310400005)(4743002)(186003)(36756003)(6506007)(8936002)(40480700001)(2616005)(6486002)(316002)(86362001)(70206006)(356005)(478600001)(6916009)(82740400003)(70586007)(336012)(8676002)(26005)(6666004)(40460700003)(235185007)(4326008)(6512007)(47076005)(44144004)(2906002)(83380400001)(44832011)(33964004)(36860700001)(5660300002)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 09:25:12.9572 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8dabb9e7-2080-46dc-2614-08da9d4584a7 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5386 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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-Patchwork-Original-From: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Cc: richard.sandiford@arm.com, nd@arm.com, rguenther@suse.de Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744752003356836673?= X-GMAIL-MSGID: =?utf-8?q?1744752003356836673?= Hi All, This is an RFC to figure out how to deal with targets that don't have native comparisons against QImode values. Booleans, at least in C99 and higher are 0-1 valued. This means that we only really need to test a single bit. However in RTL we no longer have this information available and just have an SImode value (due to the promotion of QImode to SImode). This RFC fixes it by emitting an explicit & 1 during the expansion of the conditional branch. However it's unlikely that we want to do this unconditionally. Most targets I've tested seem to have harmless code changes, like x86 changes from testb to andl, $1. So I have two questions: 1. Should I limit this behind a target macro? Or should I just leave it for all targets and deal with the fallout. 2. How can I tell whether the C99 0-1 values bools are being used or the older 0, non-0 variant? Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. However there are some benign codegen changes on x86, testb changed to andl $1. This pattern occurs more than 120,000 times in SPECCPU 2017 and so is quite common. Thanks, Tamar gcc/ChangeLog: * tree.h (tree_zero_one_valued_p): New. * dojump.cc (do_jump): Add & 1 if truth type. --- inline copy of patch -- diff --git a/gcc/dojump.cc b/gcc/dojump.cc index 2af0cd1aca3b6af13d5d8799094ee93f18022296..8eaf1be49cd12298e61c6946ae79ca9de6197864 100644 --- diff --git a/gcc/dojump.cc b/gcc/dojump.cc index 2af0cd1aca3b6af13d5d8799094ee93f18022296..8eaf1be49cd12298e61c6946ae79ca9de6197864 100644 --- a/gcc/dojump.cc +++ b/gcc/dojump.cc @@ -605,7 +605,17 @@ do_jump (tree exp, rtx_code_label *if_false_label, /* Fall through and generate the normal code. */ default: normal: - temp = expand_normal (exp); + tree cmp = exp; + /* If the expression is a truth type then explicitly generate an & 1 + to indicate to the target that it's a zero-one values type. This + allows the target to further optimize the comparison should it + choose to. */ + if (tree_zero_one_valued_p (exp)) + { + type = TREE_TYPE (exp); + cmp = build2 (BIT_AND_EXPR, type, exp, build_int_cstu (type, 1)); + } + temp = expand_normal (cmp); do_pending_stack_adjust (); /* The RTL optimizers prefer comparisons against pseudos. */ if (GET_CODE (temp) == SUBREG) diff --git a/gcc/tree.h b/gcc/tree.h index 8f8a9660c9e0605eb516de194640b8c1b531b798..be3d2dee82f692e81082cf21c878c10f9fe9e1f1 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4690,6 +4690,7 @@ extern tree signed_or_unsigned_type_for (int, tree); extern tree signed_type_for (tree); extern tree unsigned_type_for (tree); extern bool is_truth_type_for (tree, tree); +extern bool tree_zero_one_valued_p (tree); extern tree truth_type_for (tree); extern tree build_pointer_type_for_mode (tree, machine_mode, bool); extern tree build_pointer_type (tree); --- a/gcc/dojump.cc +++ b/gcc/dojump.cc @@ -605,7 +605,17 @@ do_jump (tree exp, rtx_code_label *if_false_label, /* Fall through and generate the normal code. */ default: normal: - temp = expand_normal (exp); + tree cmp = exp; + /* If the expression is a truth type then explicitly generate an & 1 + to indicate to the target that it's a zero-one values type. This + allows the target to further optimize the comparison should it + choose to. */ + if (tree_zero_one_valued_p (exp)) + { + type = TREE_TYPE (exp); + cmp = build2 (BIT_AND_EXPR, type, exp, build_int_cstu (type, 1)); + } + temp = expand_normal (cmp); do_pending_stack_adjust (); /* The RTL optimizers prefer comparisons against pseudos. */ if (GET_CODE (temp) == SUBREG) diff --git a/gcc/tree.h b/gcc/tree.h index 8f8a9660c9e0605eb516de194640b8c1b531b798..be3d2dee82f692e81082cf21c878c10f9fe9e1f1 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4690,6 +4690,7 @@ extern tree signed_or_unsigned_type_for (int, tree); extern tree signed_type_for (tree); extern tree unsigned_type_for (tree); extern bool is_truth_type_for (tree, tree); +extern bool tree_zero_one_valued_p (tree); extern tree truth_type_for (tree); extern tree build_pointer_type_for_mode (tree, machine_mode, bool); extern tree build_pointer_type (tree);