From patchwork Tue Aug 30 06:35:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 57162 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2F133AA8010 for ; Tue, 30 Aug 2022 06:36:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2F133AA8010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661841389; bh=csXeaniMMtFW6hef8h601VfDaK+dywyj+cVcTJcUHD4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=y03Slc+cP2GyJRWh1/6u8j33Ya3FikbvXHBIVgCOFkBBdiQi+9MepfMzEygg5s/zP yYUKw7SfkcrXbj3AybhcPifusDT0MRZVb9SDYyMPOr5n6APCJLwmzMscS/7OAn1ZG7 ZvVHfQuMUPIQwAZXnQeQeCMHgbYmUmA2hJ3HbiY4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70054.outbound.protection.outlook.com [40.107.7.54]) by sourceware.org (Postfix) with ESMTPS id 17E3539960E0 for ; Tue, 30 Aug 2022 06:35:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17E3539960E0 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=XBAoktI2xmuYO8HuCB14F5SiKX0n/rWffxNlmDWF5o35xJN4Yzif4rnmjNcLOQeF1GO6WkPqGphCuL1PYj/V/rCSZ3UJdnAevaGFWPxbQIBQpJiTujGw7dy++tFIENKR8bYrL0GDwsUVPqE1wiRQB5Xj2flSWMCTsMyn3TEBlpkc21BSQD8Y9vxZc/ROoD2tMY4Osyturxhw9+tBR+211FNOMs0vmjMZahJ1jlHyBzKEahTihgfJglgnxE1KuNkgD8RwyMiqJZz0i0KrfYVlNBFX1IIw8skYszAWVI5simT97pfgJ5Xxb2Jn9PhP/dlE20kKgvOaKoLOUuEdEzuavg== 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=csXeaniMMtFW6hef8h601VfDaK+dywyj+cVcTJcUHD4=; b=K3OyswnIekKa0wI3DrI5RzgYtclJwVRb7oWMWy93XqL1shvWadIWHD1FGalPNq8cDweV1nkYHd3D1slPfJHN73FNJ/QB9e/DW68hfxe2pQ0xTrO5XL5IDbRuBJo0EQbA5DgzunZpyxJx+URpSSo2Ygl8D7HnyX9IiojAEWUaEPedmOhJghOV2mk3vSQLf8lqOtGcq4c4YJRM8wmc63MWJn2cjOvduCrpen1dC5yfaZhHjDr70rLAOQSZmVMhQsKjXp/vepjcGeuIAT/c8OdYvrHPGR8mZyCRXZP8cX03q1XeClr7f2konAL9rgiZUEXn5RzTrd9QVGs2BaIBl9Gi3A== 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 AM5PR0201CA0012.eurprd02.prod.outlook.com (2603:10a6:203:3d::22) by AM8PR08MB6321.eurprd08.prod.outlook.com (2603:10a6:20b:366::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Tue, 30 Aug 2022 06:35:38 +0000 Received: from AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:3d:cafe::e0) by AM5PR0201CA0012.outlook.office365.com (2603:10a6:203:3d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21 via Frontend Transport; Tue, 30 Aug 2022 06:35:38 +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 AM7EUR03FT057.mail.protection.outlook.com (100.127.140.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Tue, 30 Aug 2022 06:35:37 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Tue, 30 Aug 2022 06:35:37 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8322fe8d1c36caf4 X-CR-MTA-TID: 64aa7808 Received: from b6764b8f4224.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F5989570-6808-4547-9578-DED1F7D04524.1; Tue, 30 Aug 2022 06:35:30 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b6764b8f4224.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 30 Aug 2022 06:35:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LwBH9swJdfRqFcuhl15GKkUtE68jyt7AGJgLaQqYZs6UsJNaCVtO5NcQ+5vLf6fqq+lrDpdr7iftzR3V7UEg+h8kUVTizX4XwGGtNEQ8RmlMbEYQua8TzxabToZMFpGTmxvxw4oneIHNOEnffcPMkihe0Ah4g73b1OeBFk5e/8DziIHHXeRaCkAv3+odfETi8tvMOy04SWUB4wrE//eyHPKRq5xZOf1HZl1h2ibIQOAXay3Mip1yYp/MUO2yFayQFvmlVIpUtRHhNrS8iLVWqdx4Vm70pqvZzXqyWNwK2UA6pKymZtXetSZYp5QbA9s5C26619dYZLzSA+Xh3teCOA== 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=csXeaniMMtFW6hef8h601VfDaK+dywyj+cVcTJcUHD4=; b=CzzrT6O8SFRWw/c2Fx7cIisa7InqflKXjkxhNekYm9W1yDorZ5WS5nog9nm16ye5NoUusEjdKAEo7RWm4IyY1Ml1ChJUx3lyONiOy9bZkW4N/usFQnj/qeTFkV9LX7lgEpCS2buQpJyfEMiKYY9H3Di6UbvJ81N/xwnJdKB3gvdxMTy9R+/Num02Dt88bDG2cOQxOCX7EWlKdIoSUOXRM9DxngCJHOw1GuRzgEYd7HaqmTjCA5DQS0GBanFuH7XwdDgHwvvMRbnMX0PnHIvYJMQ2g/dQDdFMb0UVAIGqyboCqYMT1cE4mpPHosVarfdA6kxRBGreaoOpph7m+3H3Iw== 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 GV1PR08MB8689.eurprd08.prod.outlook.com (2603:10a6:150:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Tue, 30 Aug 2022 06:35:27 +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.5566.021; Tue, 30 Aug 2022 06:35:27 +0000 Date: Tue, 30 Aug 2022 07:35:19 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH]middle-end: fix min/max phiopts reduction [PR106744] Message-ID: Content-Disposition: inline X-ClientProxiedBy: SA1PR02CA0012.namprd02.prod.outlook.com (2603:10b6:806:2cf::17) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 942017f3-bd15-4734-317b-08da8a51d9ec X-MS-TrafficTypeDiagnostic: GV1PR08MB8689:EE_|AM7EUR03FT057:EE_|AM8PR08MB6321:EE_ 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: gu5hKhGOCYpFvxNUG/Qy1hMAWhudBrOdGpwCPt118p8jZjEZZdQhaof+n68M6lckOTPs73XoPGxLqSEHpdW3b7xJ1D9QQkxgu5ZSU0D8CDdXPBH134eKyIJj8HdJJMFBjSt73CqAIKZDV+aj1YPHXkmdPYaA7xBAC2Xv55a2vmGOaFWwc7ARkFUxsix7bwuW7Z1v3d8kCSobEH/MBPwKs1Q8sQfaMRjnh8szzDUrx2YLLdIjsDa/Y+VMU93vIVgAzMWYck/JVIIv44kTsx4cq4eblYFANMuY/O4Kfk0qnjXsnCcSs0snXHDtld6Y4zxMrswIGhTx1FSZkEJxwDYPPtAsr7Yz3J1Sam64mxCf47MfScUpRsPIjIglM5zw5IEPBWtBwSt+5YWL9HRadOUnxdrAXwoikefueI9ullsQ7PvI72cqb0ODfIzd9DPXJC8uT5kwaj6RGZtVITHy5rhydttSK5w2ma5FBsXarEl8A+BoEMN9IVcFqZ5f4U8QxDCy24eWEQCrhRsI/SmkglvGHTyvwqlJDOiuBiojDcH/sk2VqiqY+kZ1O8k/fcYa4ai5CG1ZRwBSxEdKcuW4B3uJoRiDBunNPPAYr+sMOMffl1VAIWMP7wyex1h+lL5s9ntVcmHMO1EEEa+xCarudzAVWFUcM0NaaoIIeuRyG1wQWyYjh4l+v94xCPqPYYBTIkHKGJWBcsvmBrQpcXRL1Pej7cuO2ac/nyT9UBdktUeuLOzXmV+4D/bbAOiGlUPGHKaERM6oL7DCw1SJv+DGN7JRk1IB74N7/nHpeOpyFbBpj0vha0L/bsBkrzNl3JvES52AXqVaabaZtZHAZSBI8kjiaJnTP+W4V+HgGa4oCVzIxvE= 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:(13230016)(4636009)(136003)(366004)(39860400002)(396003)(376002)(346002)(83380400001)(478600001)(86362001)(6916009)(316002)(186003)(2616005)(4743002)(6506007)(33964004)(44144004)(41300700001)(38100700002)(44832011)(2906002)(6486002)(4326008)(66946007)(235185007)(6512007)(26005)(6666004)(84970400001)(8676002)(66476007)(66556008)(30864003)(5660300002)(36756003)(8936002)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8689 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: AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1e13c0b9-b281-439f-0db5-08da8a51d312 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D9R/aFgT36Q6u2sKc3LPj1FoaeB41SAfgLEdUOO6rBAKlIqXynGqGWV9nWCJL7RyZQEiJZMJs7fWox/HTl0z5uaaTdf+PxYOOOIjTrjR6jkRaThp63P1NckOMqCsTsdfeFrtO+hYKsnoE/UyGHVVLftIZ/LGdYEJ9fZnNxl5hEw3X+EXkjZobR1ljyeCWfazD6A2v2ZEfVc+oClnQ+nlIaZFnA7Ir+EWlOP3M6HogozzPqbh9JW7Q7Q7ARzWR7eM2+4fMYMOONBBUH9MhnlCljxgsJUIFolWFyb1GPY1EUbqb1yFyTSVKiqCqbpYFV04BsH61b5WnRhSlEKD2847AucP/ZQbSoidSVI93fUs8LtaXkceyCbTipetW6tn9rHthDvoklK8lc9g/gFHIkgG6HHvrAR8ka6Hked639+LMGfbkraTB7OKPXsN25KQp9P4Pj7NUR9Ve0gdXQSoTT3XjtzeG4YZ+PB5JJda75CzUq49mrOttA41oW6BP7WVnHmYfhyMGLHLJhjPup9jMTxb4aydod+uXD/oqli/LMJ+ARwf3LAK1zrvwoCmUjKjgPvaQ5foLgSV/85LkvWpdnTAJNm0iSymWpwpDxJxNhl+JAy/hNoPC0Uwvcn/VbbThX9M8hY92CSJOSwHkCehq8ftri0kWNSZuvsyLIZR8tXv7001WWNFvkeMf/NXltTXf/1cW+asEMeI2z8ppnWLpSK6NutarmMhEcdN/chcz7LWM13+VBpm9q8VPseEZxRAdbeR6jCIpTdBb/ntuLpAjZIcuvTOzrUQJhVSvlilppc1jmn+r7KG9NSm6KCGXpvZb375QcnkHUeyKtRTp7LstCQ9JTpqwcu0gpmoKchKFuFQUOIvCDJQAZezTJtxEjcxSQg3nZiQ22yU6iLqzH7nq2F+og== 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:(13230016)(4636009)(346002)(376002)(136003)(396003)(39860400002)(36840700001)(46966006)(40470700004)(107886003)(2616005)(336012)(2906002)(186003)(47076005)(316002)(6916009)(6512007)(36756003)(84970400001)(44144004)(30864003)(6666004)(44832011)(33964004)(83380400001)(6506007)(26005)(4743002)(86362001)(40460700003)(356005)(82740400003)(82310400005)(40480700001)(36860700001)(5660300002)(8936002)(6486002)(478600001)(41300700001)(81166007)(235185007)(70206006)(4326008)(8676002)(70586007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2022 06:35:37.8684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 942017f3-bd15-4734-317b-08da8a51d9ec 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: AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6321 X-Spam-Status: No, score=-12.6 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, T_SCC_BODY_TEXT_LINE, 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: nd@arm.com, rguenther@suse.de Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi All, This corrects the argument usage to use them in the order that they occur in the comparisons in gimple. This was tested by disabling the pass, adding the runtime checks and re-enabling the pass and verifying the tests still pass. Also tested that the runtime test caught the issue by updating the tests on an unpatched tree and observing that some fail. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/106744 * tree-ssa-phiopt.cc (minmax_replacement): Correct arguments. gcc/testsuite/ChangeLog: PR tree-optimization/106744 * gcc.dg/tree-ssa/minmax-10.c: Make runtime test. * gcc.dg/tree-ssa/minmax-11.c: Likewise. * gcc.dg/tree-ssa/minmax-12.c: Likewise. * gcc.dg/tree-ssa/minmax-13.c: Likewise. * gcc.dg/tree-ssa/minmax-14.c: Likewise. * gcc.dg/tree-ssa/minmax-15.c: Likewise. * gcc.dg/tree-ssa/minmax-16.c: Likewise. * gcc.dg/tree-ssa/minmax-3.c: Likewise. * gcc.dg/tree-ssa/minmax-4.c: Likewise. * gcc.dg/tree-ssa/minmax-5.c: Likewise. * gcc.dg/tree-ssa/minmax-6.c: Likewise. * gcc.dg/tree-ssa/minmax-7.c: Likewise. * gcc.dg/tree-ssa/minmax-8.c: Likewise. * gcc.dg/tree-ssa/minmax-9.c: Likewise. --- inline copy of patch -- diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c index 589953684416a9d263084deb58f6cde7094dd517..c9322a17a4af8e01add2f04176805c812af62e07 100644 --- diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c index 589953684416a9d263084deb58f6cde7094dd517..c9322a17a4af8e01add2f04176805c812af62e07 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,5 +17,16 @@ uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_max (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */ /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c index 1c2ef01b5d1e639fbf95bb5ca473b63cc98e9df1..b1da41712b342cd7344167a0da91ffd419491391 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c @@ -1,8 +1,10 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include + +__attribute__ ((noipa, noinline)) uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,6 +18,17 @@ uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax1 (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c index 3d0c07d9b57dd689bcb89653937727ab441e7f2b..cb9188f90e8e12c6244d559e63723177102177ee 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noinline, noipa)) uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,5 +17,16 @@ uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax3 (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c index c0d0f27c8027ae87654532d1b919cfeccf4413e0..62ba71e8c3f21f1cb33ae2473fd2b30bfdc13c81 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -15,5 +16,17 @@ uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { } return xk; } + +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 127; + volatile uint8_t xc = 0; + if (three_minmax2 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c index 9c0cadbf7e3119527cb2007d01fe4c7dd772c069..a3ec58460838ebbcfa5451a2471dde07608a38e3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,6 +17,17 @@ uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax11 (xc, xm, xy) != 128) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c index 1d97a16564f069b4348ff325c4fd713a224f838a..8a39871c93890b553dc8d4aed494c2f14f8508fe 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c @@ -1,10 +1,11 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include #include -uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy, bool m) { +__attribute__ ((noinline, noipa)) +uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc) { @@ -17,5 +18,17 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy, bool m) { return xk; } + +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c index 89377a2cb341bdafa6ba145c61c1f966af536839..4febd092d837542017438bcc4f8554fdb05c4adf 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt -g" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc < xm) { @@ -13,5 +14,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c index de3b2e946e81701e3b75f580e6a843695a05786e..2af107763469cd16401b618f0e6b556e5ac2b04d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc < xm) { @@ -13,5 +14,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c index 0b6d667be868c2405eaefd17cb522da44bafa0e2..973f39bfed305d636cd7290ab5dbb726d6d75f12 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -13,5 +14,16 @@ uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_max (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c index 650601a3cc75d09a9e6e54a35f5b9993074f8510..34e4e7205111b6c3e28fbe7c8cde85740ac52630 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -13,5 +14,16 @@ uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax1 (xc, xm, xy) != 127) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c index a628f6d99222958cfd8c410f0e85639e3a49dd4b..443d68f826db91118ff8fa4f62333f660fdf5546 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -13,5 +14,16 @@ uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax3 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c index cb42412c4ada433b2f59df0a8bef9fa7b1c5e104..7e2a3f08060bc84f33ad416a4c89d0ef74dc9cb3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -12,5 +13,17 @@ uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { } return xk; } + +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax2 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c index 9cd050e932376bc50bd6ae60cb654fcab0bfdd1c..0160e573fef8aba106d4f8ef86b5c958ab52cb30 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noinline, noipa)) uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc < xm) { @@ -13,5 +14,16 @@ uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax11 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c index 24f580271c3ac3945860b506d4dc7d178a826093..0cfb65845889af4f25f7c6c57264617a72cda0ad 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,5 +17,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "optimized" } } */ diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index d5f2ba8be1c33e3ea441a61e9dbf8867aee93a98..925bd7d885357dce114a9b29176d953e30ae3b4d 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -2150,9 +2150,9 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_ gimple_seq stmts = NULL; tree phi_result = PHI_RESULT (phi); result = gimple_build (&stmts, locus, minmax, TREE_TYPE (phi_result), - arg0, bound); + arg0, arg1); result = gimple_build (&stmts, locus, ass_code, TREE_TYPE (phi_result), - result, arg1); + result, bound); if (invert) result = gimple_build (&stmts, locus, BIT_NOT_EXPR, TREE_TYPE (phi_result), result); --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,5 +17,16 @@ uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_max (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */ /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c index 1c2ef01b5d1e639fbf95bb5ca473b63cc98e9df1..b1da41712b342cd7344167a0da91ffd419491391 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c @@ -1,8 +1,10 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include + +__attribute__ ((noipa, noinline)) uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,6 +18,17 @@ uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax1 (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c index 3d0c07d9b57dd689bcb89653937727ab441e7f2b..cb9188f90e8e12c6244d559e63723177102177ee 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noinline, noipa)) uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,5 +17,16 @@ uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax3 (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c index c0d0f27c8027ae87654532d1b919cfeccf4413e0..62ba71e8c3f21f1cb33ae2473fd2b30bfdc13c81 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -15,5 +16,17 @@ uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { } return xk; } + +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 127; + volatile uint8_t xc = 0; + if (three_minmax2 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c index 9c0cadbf7e3119527cb2007d01fe4c7dd772c069..a3ec58460838ebbcfa5451a2471dde07608a38e3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,6 +17,17 @@ uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax11 (xc, xm, xy) != 128) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c index 1d97a16564f069b4348ff325c4fd713a224f838a..8a39871c93890b553dc8d4aed494c2f14f8508fe 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c @@ -1,10 +1,11 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include #include -uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy, bool m) { +__attribute__ ((noinline, noipa)) +uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc) { @@ -17,5 +18,17 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy, bool m) { return xk; } + +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c index 89377a2cb341bdafa6ba145c61c1f966af536839..4febd092d837542017438bcc4f8554fdb05c4adf 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt -g" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc < xm) { @@ -13,5 +14,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c index de3b2e946e81701e3b75f580e6a843695a05786e..2af107763469cd16401b618f0e6b556e5ac2b04d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc < xm) { @@ -13,5 +14,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c index 0b6d667be868c2405eaefd17cb522da44bafa0e2..973f39bfed305d636cd7290ab5dbb726d6d75f12 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -13,5 +14,16 @@ uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_max (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c index 650601a3cc75d09a9e6e54a35f5b9993074f8510..34e4e7205111b6c3e28fbe7c8cde85740ac52630 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -13,5 +14,16 @@ uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax1 (xc, xm, xy) != 127) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c index a628f6d99222958cfd8c410f0e85639e3a49dd4b..443d68f826db91118ff8fa4f62333f660fdf5546 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -13,5 +14,16 @@ uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax3 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c index cb42412c4ada433b2f59df0a8bef9fa7b1c5e104..7e2a3f08060bc84f33ad416a4c89d0ef74dc9cb3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc > xm) { @@ -12,5 +13,17 @@ uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { } return xk; } + +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax2 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c index 9cd050e932376bc50bd6ae60cb654fcab0bfdd1c..0160e573fef8aba106d4f8ef86b5c958ab52cb30 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-phiopt" } */ #include +__attribute__ ((noinline, noipa)) uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; if (xc < xm) { @@ -13,5 +14,16 @@ uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_minmax11 (xc, xm, xy) != 255) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c index 24f580271c3ac3945860b506d4dc7d178a826093..0cfb65845889af4f25f7c6c57264617a72cda0ad 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c @@ -1,8 +1,9 @@ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ #include +__attribute__ ((noipa, noinline)) uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { uint8_t xk; xc=~xc; @@ -16,5 +17,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { return xk; } +int +main (void) +{ + volatile uint8_t xy = 255; + volatile uint8_t xm = 0; + volatile uint8_t xc = 127; + if (three_min (xc, xm, xy) != 0) + __builtin_abort (); + return 0; +} + /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "optimized" } } */ diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index d5f2ba8be1c33e3ea441a61e9dbf8867aee93a98..925bd7d885357dce114a9b29176d953e30ae3b4d 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -2150,9 +2150,9 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_ gimple_seq stmts = NULL; tree phi_result = PHI_RESULT (phi); result = gimple_build (&stmts, locus, minmax, TREE_TYPE (phi_result), - arg0, bound); + arg0, arg1); result = gimple_build (&stmts, locus, ass_code, TREE_TYPE (phi_result), - result, arg1); + result, bound); if (invert) result = gimple_build (&stmts, locus, BIT_NOT_EXPR, TREE_TYPE (phi_result), result);