From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2070.outbound.protection.outlook.com [40.107.21.70]) by sourceware.org (Postfix) with ESMTPS id 233413858C62 for ; Fri, 8 Dec 2023 13:46:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 233413858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 233413858C62 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.21.70 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702043188; cv=pass; b=EyDbrEcSdwyURvImT70D+rSg7RJaM6e0tC5GkGDaVqa+dShqmN/0iSc35NNb1WitgXPAzJhbPH4DaJNfcGkxwrzvoqmTDbqYifzx0O6stSbBVIO7+fnULUCoHqOvWIfj4zEEcvpu6xFYKivNVCcjc8jrDBiCAzca4QBpbxeido8= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1702043188; c=relaxed/simple; bh=e3bbZV+FlR+vlYM16dEOHKHbVdLYe0pq+KDXSQULp/w=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=moP1GCUwdS47FNdPevTENsqLXk+qmZrL8BWC7tW+N4bmtAEPG+9fmPJLBSIjCgWzmPFHArVFdXaQlKOL5ZSEIQoMs7Qjd4rz6OtVLsHINuT1gD4S7rejpZVd9rkKWINO0Te+vIMU+BxzsZbvnt9jbmy/I6IFajNwFUhLyaqzEqw= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=iCPPMHnVt5BmHFBHHXW4MA5LqlWW4vn+qTwTWiAMIdbvkBxFqSTO7fXEcs7+QuFNEl5z2ImOaKT5/kuxTeW541nKY2KouBXZTTwpAxH09p7uY27Y0sHKCBck/L+ZI0npNWjvGnt/+tQmlrDCeh6gVrI+wo9vmSXhay3gMs5IqL3f5o40Klh0c+dgZHa2nfn9027Fpt0aJPwYwxpKLoG088EaiuR5Wx53mNoA5HC/4R8C64suYtgQZnvGZWAlhVz5pWwacuTZrVBtgnAy0mBdic0YRlojO84OO5q1FIt9tfneaBZHnrrvYSci7mse3AYiAElRc4y6aQm2yCofAzr1XA== 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=m34Qcix8jyfx3+t7tfVBBR8LdEwYXEU3macWlkW/Z7U=; b=DC3PeaJbzxbkLYjTh+a/vilaPQ8g7YmvSGaF6CYnwCpRsLucqY1DgBx10052AqEqSDVSG/9569NyXT45H9F0imWbv4Z0jXKDkgEa+bX1hFPf/enkNBwiJ7E+U50gdlQHFGDllbpi4NdJRyk0BNAartcSbAEvUsk7Dj74DLxZjOaEnfiTIHVLb8VRxBzfnbGPWRvrhALJpo3ulAT4j/E6rUfLEaaHf9djcAT2TynvoYscJcDcx20mZIPQ/rOw1CInbbPkd8glTiru4YpSZ+MSSSDNfOwYZDYI33sCGupUTVBWJ/V1QXdOd0VLVxrZcgJYnuukOG/inwDLVFfrYEGY0w== 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]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m34Qcix8jyfx3+t7tfVBBR8LdEwYXEU3macWlkW/Z7U=; b=vZ2csxLA3InwPbMNQpqJa6HVqA29joOXPDs8wHG/ykLfhTOlu7PMJQKBj7lu0+/oHLaQO1mkCWnTXsKMnjSPDMGXcG64yFZ68AFu3auH7OcELAlox/JvJ6HOb/sj2OHCRwwMEfF2JjW7pLtT4+ZxZV8rvN/E188IsMWhsPYKFB4= Received: from DU2PR04CA0157.eurprd04.prod.outlook.com (2603:10a6:10:2b0::12) by DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28; Fri, 8 Dec 2023 13:46:15 +0000 Received: from DB5PEPF00014B90.eurprd02.prod.outlook.com (2603:10a6:10:2b0:cafe::a1) by DU2PR04CA0157.outlook.office365.com (2603:10a6:10:2b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Fri, 8 Dec 2023 13:46:15 +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 DB5PEPF00014B90.mail.protection.outlook.com (10.167.8.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.20 via Frontend Transport; Fri, 8 Dec 2023 13:46:15 +0000 Received: ("Tessian outbound 7c4ecdadb9e7:v228"); Fri, 08 Dec 2023 13:46:15 +0000 X-CR-MTA-TID: 64aa7808 Received: from 0137012b4de6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6C8909FB-C917-4BB4-A57E-D32C1728DA82.1; Fri, 08 Dec 2023 13:45:53 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0137012b4de6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 08 Dec 2023 13:45:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j78lSCXlsQQl0PSTRtnvg29jEMe1cjAfaDXhpq5/f23lABiMCqM+v5v/Y62F0Nu4Cd1k5sxamH/OTsTcE3N6BpFt/XtVtTGCvxocQwWUd1yKJyrXwXhPEI+mMmPAPNl0Br1Bz9FSezLg59sjV8BJxeIyVyS1Ez9+3pIULmt0yQAT1TZ6UJvpZKKWRTjf1Gh34Rh6pqh6PhFfWP5JBKrDm8rkVKdMX+/Bpq9v/MCW7uEcW09E+YlK6RmU0pGkcaVjim72+mqqQJsrOXQYMY7mpafIwD8diMCgE7mcnkcYOhqoClQv1oUkHPNbtwYh/SpnnJ+rYROGHMC5cCnJUn31Tw== 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=m34Qcix8jyfx3+t7tfVBBR8LdEwYXEU3macWlkW/Z7U=; b=X8NHk+vH+TGuII//HRY7XscsO3duJdKQx7GuRQH04TucMygV0EeBZjnnko7awfDgzlirI9MxfwRZMh1Uiyelb3UicNkewCJqOuBHApC3EWbypkUAC7c3fy3tZdpXLkE6bU9CRx52dtiC9oN/TRbcdodvIHaLAs04eoSA4KpGLgFEBZbcGDJuatBfdRo5D2duNjo8aDVV267Xf2Nc3p/W8xARfm1v1Y+TEjyFAcCRrsCWuVbhvliMW7LNi+Ko0awYYNmSZIjdOsL50/vUwDOmZ8F9F50nck2npMTR4qNAL96S11Bpl2t+ouVrU8uOEdrGkaXmzDDBL6Xzgu6KlEhrWg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m34Qcix8jyfx3+t7tfVBBR8LdEwYXEU3macWlkW/Z7U=; b=vZ2csxLA3InwPbMNQpqJa6HVqA29joOXPDs8wHG/ykLfhTOlu7PMJQKBj7lu0+/oHLaQO1mkCWnTXsKMnjSPDMGXcG64yFZ68AFu3auH7OcELAlox/JvJ6HOb/sj2OHCRwwMEfF2JjW7pLtT4+ZxZV8rvN/E188IsMWhsPYKFB4= Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by GVXPR08MB10863.eurprd08.prod.outlook.com (2603:10a6:150:154::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28; Fri, 8 Dec 2023 13:45:44 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3%6]) with mapi id 15.20.7068.027; Fri, 8 Dec 2023 13:45:43 +0000 From: Tamar Christina To: Richard Biener CC: "gcc-patches@gcc.gnu.org" , nd , "jlaw@ventanamicro.com" Subject: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Thread-Topic: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code Thread-Index: AQHaEIRpInfkk2iMNkKe/ayk/lXCPbCO5tuwgAKOHoCACmF78IAAWBaAgAMYIGCAABrAgIAAAmcw Date: Fri, 8 Dec 2023 13:45:43 +0000 Message-ID: References: <85570n66-1540-0r07-7q80-269p3o133585@fhfr.qr> <5r3p7378-q309-ooqo-7o76-q9r567ns1890@fhfr.qr> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: VI1PR08MB5325:EE_|GVXPR08MB10863:EE_|DB5PEPF00014B90:EE_|DB9PR08MB6748:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ecac427-6703-4c41-949c-08dbf7f40c3d 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: d4ErrTirsYo8sB/dvkmxCYmSDeJG+3gZv3fOGEWy2bb/onuRG6F4WAGnyihMREaqeEmT23V7ejkjw8r7MOwZxVBeOigL5KCOlF6uEEKDN00vg6qIOyMoF7RWDQ+lg1n0xhNSjmi4BLha1Nb2LOYH6+FljgTGyw6z8ApPFwMwlazl9SCOji65wfrLDUzQelm1eSAYiX1wu9MQujKcbx8FgywhbY9NbP6+i48TZbvpEewEFJ9jJ94ysClt/Eeq3i0hAL6NMave+jkSFmS6Ja0O5t116TNqWjM2ayk8aAz9GJFdSXfs7yMfK3sAZEKf3AEnVw+sIoUE15t1daq1AQk0NhgUO1aO6SUepHt+Tcpu0+SC96/uvLf+v+zytXHfTXkUBg6gyuFARPGWc7f/sj0Spca//w2Th/6eS0OhIKV3vbj4IUYdp7Y4M7WD01o/YIs9Cp7uchLa/oeL2xHYLvNu0vFR2ItsnVEm04iJggIRs5UE4nEDUYQjxVyJ4wS70eAnqzaOXIqEULvEC5+pLl8a6n+HcNibHhuyY2Z2G7lSjifY4hcva3cYj9Ij358/QwAp8FYKh1/q4bj+j6TTskkdew0NbVF/FFS4eMNHTfTsCXDteIPt/bu1WLWP/PYxXWgW 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:(13230031)(396003)(39860400002)(136003)(366004)(346002)(376002)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(30864003)(2906002)(5660300002)(41300700001)(52536014)(54906003)(86362001)(66946007)(66446008)(66556008)(38100700002)(122000001)(66476007)(64756008)(478600001)(6506007)(53546011)(6916009)(7696005)(76116006)(83380400001)(33656002)(9686003)(316002)(8676002)(38070700009)(8936002)(4326008)(26005)(71200400001)(55016003)(579004)(559001);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10863 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: DB5PEPF00014B90.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5008be17-2025-445d-20a7-08dbf7f3f987 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IUP54NRg2jvXWwOgQR27+bQ3Trqb6loRtEZ+91thcbAR/J1CBqy+pzRyip2fLZ3sL0+u99+jheNv8gD+SiJT/fNin7FCjeJLc/AEAAO/X2OB9Wg2rih/EBp03gucZFK0amr+QVu4EAIk2vXDIoXg+F+p/Ccp+hpvVrYNihP8KDP2wc0HiM7J9bhAqni4/oP+efs6raY4XUjMT7BNneaOkcUsqdaidG0e/IUUAcUETwSOk8u887lXEygFKW0cvsYy95Poe8Xv7ILgRIZqm/C85ibzITSFJIGoOhOi80y6dEVWqYzv7cr7Eilh22gcWI6r+KG1TOdLmLcj/kN0APbDAxGX+AW1+D/IEt/Vse69aIrpiAI56ieCgPk1d67XzqOVnp739PdUyg++eAa53ANpMffA+CcnmsLfgN0leyp9yL8zXO3bk3+3ngwFTf0IU7mnDbc7xhzmqhxNRVj5+zj+WuYf6gJgRD1C0UgfOqOS2RQ402uYrUwCjOVts96JNcQiOb7qOh2ODxqCZjFy/FkFv8/UcE945DV8LCBT2nXyFrNZIYsmKgfkhdB2ZMVorVKkrAiVpL7DrmwFht8KQhBnLUV4jFL1oU63pzmeWju7yNU6x/xjmhhKJv6sCXrB/aFb9X7CERHOlnllFSVjiB7zPPb+Ap9aU7mA3YL4ysg5QPqPm7RPhXYdsh1fjbDIC5P31sLZBk5CZujJS1e8TUXuBJL6Hevitq0pcIvK3ZBU9DD37evw3kwaetj/PzqjuQwK 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:(13230031)(4636009)(39860400002)(396003)(136003)(376002)(346002)(230922051799003)(82310400011)(186009)(64100799003)(451199024)(1800799012)(40470700004)(46966006)(36840700001)(53546011)(9686003)(30864003)(2906002)(47076005)(36860700001)(5660300002)(41300700001)(86362001)(33656002)(82740400003)(81166007)(356005)(107886003)(26005)(6506007)(478600001)(4326008)(6862004)(7696005)(8936002)(52536014)(316002)(8676002)(83380400001)(54906003)(336012)(70586007)(70206006)(55016003)(40480700001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2023 13:46:15.2500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ecac427-6703-4c41-949c-08dbf7f40c3d 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: DB5PEPF00014B90.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6748 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,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 List-Id: > -----Original Message----- > From: Richard Biener > Sent: Friday, December 8, 2023 10:28 AM > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd ; jlaw@ventanamicro.com > Subject: RE: [PATCH 9/21]middle-end: implement vectorizable_early_exit fo= r > codegen of exit code >=20 > On Fri, 8 Dec 2023, Tamar Christina wrote: >=20 > > > --param vect-partial-vector-usage=3D2 would, no? > > > > > I.. didn't even know it went to 2! > > > > > > In principal I suppose I could mask the individual stmts, that shou= ld handle > the > > > future case when > > > > This is relaxed to supposed non-fix length buffers? > > > > > > Well, it looks wrong - either put in an assert that we start with a > > > single stmt or assert !masked_loop_p instead? Better ICE than > > > generate wrong code. > > > > > > That said, I think you need to apply the masking on the original > > > stmts[], before reducing them, no? > > > > Yeah, I've done so now. For simplicity I've just kept the final maskin= g always as > well > > and just leave it up to the optimizers to drop it when it's superfluous= . > > > > Simple testcase: > > > > #ifndef N > > #define N 837 > > #endif > > float vect_a[N]; > > unsigned vect_b[N]; > > > > unsigned test4(double x) > > { > > unsigned ret =3D 0; > > for (int i =3D 0; i < N; i++) > > { > > if (vect_a[i] > x) > > break; > > vect_a[i] =3D x; > > > > } > > return ret; > > } > > > > Looks good now. After this one there's only one patch left, the depende= ncy > analysis. > > I'm almost done with the cleanup/respin, but want to take the weekend t= o > double check and will post it first thing Monday morning. > > > > Did you want to see the testsuite changes as well again? I've basically= just added > the right dg-requires-effective and add-options etc. >=20 > Yes please. >=20 > > Thanks for all the reviews! > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > Ok for master? > > > > Thanks, > > Tamar > > > > gcc/ChangeLog: > > > > * tree-vect-patterns.cc (vect_init_pattern_stmt): Support gconds. > > (check_bool_pattern, adjust_bool_pattern, adjust_bool_stmts, > > vect_recog_bool_pattern, sort_after_uid): Support gconds type analysis= . > > * tree-vect-stmts.cc (vectorizable_comparison_1): Support stmts withou= t > > lhs. > > (vectorizable_early_exit): New. > > (vect_analyze_stmt, vect_transform_stmt): Use it. > > (vect_is_simple_use, vect_get_vector_types_for_stmt): Support gcond. > > > > > > --- inline copy of patch --- > > > > diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc > > index > 7debe7f0731673cd1bf25cd39d55e23990a73d0e..8865cde9f3481a474d31848 > ae12523576d29744d 100644 > > --- a/gcc/tree-vect-patterns.cc > > +++ b/gcc/tree-vect-patterns.cc > > @@ -132,6 +132,7 @@ vect_init_pattern_stmt (vec_info *vinfo, gimple > *pattern_stmt, > > if (!STMT_VINFO_VECTYPE (pattern_stmt_info)) > > { > > gcc_assert (!vectype > > + || is_a (pattern_stmt) > > || (VECTOR_BOOLEAN_TYPE_P (vectype) > > =3D=3D vect_use_mask_type_p (orig_stmt_info))); > > STMT_VINFO_VECTYPE (pattern_stmt_info) =3D vectype; > > @@ -5210,19 +5211,28 @@ vect_recog_mixed_size_cond_pattern (vec_info > *vinfo, > > true if bool VAR can and should be optimized that way. Assume it s= houldn't > > in case it's a result of a comparison which can be directly vectori= zed into > > a vector comparison. Fills in STMTS with all stmts visited during = the > > - walk. */ > > + walk. if ANALYZE_ONLY then only analyze the booleans but do not pe= rform > any > > + codegen associated with the boolean condition. */ > > > > static bool > > -check_bool_pattern (tree var, vec_info *vinfo, hash_set &stm= ts) > > +check_bool_pattern (tree var, vec_info *vinfo, hash_set &stm= ts, > > + bool analyze_only) > > { > > tree rhs1; > > enum tree_code rhs_code; > > + gassign *def_stmt =3D NULL; > > > > stmt_vec_info def_stmt_info =3D vect_get_internal_def (vinfo, var); > > - if (!def_stmt_info) > > + if (!def_stmt_info && !analyze_only) > > return false; > > + else if (!def_stmt_info) > > + /* If we're a only analyzing we won't be codegen-ing the statement= s and are > > + only after if the types match. In that case we can accept loop= invariant > > + values. */ > > + def_stmt =3D dyn_cast (SSA_NAME_DEF_STMT (var)); > > + else > > + def_stmt =3D dyn_cast (def_stmt_info->stmt); > > >=20 > Hmm, but we're visiting them then? I wonder how you get along > without doing adjustmens on the uses if you consider >=20 > _1 =3D a < b; > _2 =3D c !=3D d; > _3 =3D _1 | _2; > if (_3 !=3D 0) > exit loop; >=20 > thus a combined condition like >=20 > if (a < b || c !=3D d) >=20 > that we if-converted. We need to recognize that _1, _2 and _3 have > mask uses and thus possibly adjust them. >=20 > What bad happens if you drop 'analyze_only'? We're not really > rewriting anything there. You mean drop it only in the above? We then fail to update the type for the gcond. So in certain circumstances like with int a, c, d; short b; int main () { int e[1]; for (; b < 2; b++) { a =3D 0; if (b =3D=3D 28378) a =3D e[b]; if (!(d || b)) for (; c;) ; } return 0; } Unless we walk the statements regardless of whether they come from inside t= he loop or not. >=20 > > - gassign *def_stmt =3D dyn_cast (def_stmt_info->stmt); > > if (!def_stmt) > > return false; > > > > @@ -5234,27 +5244,28 @@ check_bool_pattern (tree var, vec_info *vinfo, > hash_set &stmts) > > switch (rhs_code) > > { > > case SSA_NAME: > > - if (! check_bool_pattern (rhs1, vinfo, stmts)) > > + if (! check_bool_pattern (rhs1, vinfo, stmts, analyze_only)) > > return false; > > break; > > > > CASE_CONVERT: > > if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (rhs1))) > > return false; > > - if (! check_bool_pattern (rhs1, vinfo, stmts)) > > + if (! check_bool_pattern (rhs1, vinfo, stmts, analyze_only)) > > return false; > > break; > > > > case BIT_NOT_EXPR: > > - if (! check_bool_pattern (rhs1, vinfo, stmts)) > > + if (! check_bool_pattern (rhs1, vinfo, stmts, analyze_only)) > > return false; > > break; > > > > case BIT_AND_EXPR: > > case BIT_IOR_EXPR: > > case BIT_XOR_EXPR: > > - if (! check_bool_pattern (rhs1, vinfo, stmts) > > - || ! check_bool_pattern (gimple_assign_rhs2 (def_stmt), vinfo, stmt= s)) > > + if (! check_bool_pattern (rhs1, vinfo, stmts, analyze_only) > > + || ! check_bool_pattern (gimple_assign_rhs2 (def_stmt), vinfo, stmt= s, > > + analyze_only)) > > return false; > > break; > > > > @@ -5275,6 +5286,7 @@ check_bool_pattern (tree var, vec_info *vinfo, > hash_set &stmts) > > tree mask_type =3D get_mask_type_for_scalar_type (vinfo, > > TREE_TYPE (rhs1)); > > if (mask_type > > + && !analyze_only > > && expand_vec_cmp_expr_p (comp_vectype, mask_type, rhs_code)) > > return false; > > > > @@ -5289,7 +5301,8 @@ check_bool_pattern (tree var, vec_info *vinfo, > hash_set &stmts) > > } > > else > > vecitype =3D comp_vectype; > > - if (! expand_vec_cond_expr_p (vecitype, comp_vectype, rhs_code)) > > + if (!analyze_only > > + && !expand_vec_cond_expr_p (vecitype, comp_vectype, rhs_code)) > > return false; > > } > > else > > @@ -5324,11 +5337,13 @@ adjust_bool_pattern_cast (vec_info *vinfo, > > VAR is an SSA_NAME that should be transformed from bool to a wider = integer > > type, OUT_TYPE is the desired final integer type of the whole patte= rn. > > STMT_INFO is the info of the pattern root and is where pattern stmt= s should > > - be associated with. DEFS is a map of pattern defs. */ > > + be associated with. DEFS is a map of pattern defs. If TYPE_ONLY t= hen don't > > + create new pattern statements and instead only fill LAST_STMT and D= EFS. */ > > > > static void > > adjust_bool_pattern (vec_info *vinfo, tree var, tree out_type, > > - stmt_vec_info stmt_info, hash_map &defs) > > + stmt_vec_info stmt_info, hash_map &defs, > > + gimple *&last_stmt, bool type_only) > > { > > gimple *stmt =3D SSA_NAME_DEF_STMT (var); > > enum tree_code rhs_code, def_rhs_code; > > @@ -5492,28 +5507,38 @@ adjust_bool_pattern (vec_info *vinfo, tree var,= tree > out_type, > > } > > > > gimple_set_location (pattern_stmt, loc); > > - append_pattern_def_seq (vinfo, stmt_info, pattern_stmt, > > - get_vectype_for_scalar_type (vinfo, itype)); > > + if (!type_only) > > + append_pattern_def_seq (vinfo, stmt_info, pattern_stmt, > > + get_vectype_for_scalar_type (vinfo, itype)); > > + last_stmt =3D pattern_stmt; > > defs.put (var, gimple_assign_lhs (pattern_stmt)); > > } > > > > -/* Comparison function to qsort a vector of gimple stmts after UID. *= / > > +/* Comparison function to qsort a vector of gimple stmts after BB and = UID. > > + the def of one statement can be in an earlier block than the use, s= o if > > + the BB are different, first compare by BB. */ > > > > static int > > sort_after_uid (const void *p1, const void *p2) > > { > > const gimple *stmt1 =3D *(const gimple * const *)p1; > > const gimple *stmt2 =3D *(const gimple * const *)p2; > > + if (gimple_bb (stmt1)->index !=3D gimple_bb (stmt2)->index) > > + return gimple_bb (stmt1)->index - gimple_bb (stmt2)->index; > > + >=20 > is this because you eventually get out-of-loop stmts (without UID)? >=20 No the problem I was having is that with an early exit the statement of one branch of the compare can be in a different BB than the other. The testcase specifically was this: int a, c, d; short b; int main () { int e[1]; for (; b < 2; b++) { a =3D 0; if (b =3D=3D 28378) a =3D e[b]; if (!(d || b)) for (; c;) ; } return 0; } Without debug info it happened to work: >>> p gimple_uid (bool_stmts[0]) $1 =3D 3 >>> p gimple_uid (bool_stmts[1]) $2 =3D 3 >>> p gimple_uid (bool_stmts[2]) $3 =3D 4 The first two statements got the same uid, but are in different BB in the l= oop. When we add debug, it looks like 1 bb got more debug state than the other: >>> p gimple_uid (bool_stmts[0]) $1 =3D 3 >>> p gimple_uid (bool_stmts[1]) $2 =3D 4 >>> p gimple_uid (bool_stmts[2]) $3 =3D 6 That last statement, which now has a UID of 6 used to be 3. > > return gimple_uid (stmt1) - gimple_uid (stmt2); > > } > > > > /* Create pattern stmts for all stmts participating in the bool patter= n > > specified by BOOL_STMT_SET and its root STMT_INFO with the desired = type > > - OUT_TYPE. Return the def of the pattern root. */ > > + OUT_TYPE. Return the def of the pattern root. If TYPE_ONLY the ne= w > > + statements are not emitted as pattern statements and the tree retur= ned is > > + only useful for type queries. */ > > > > static tree > > adjust_bool_stmts (vec_info *vinfo, hash_set &bool_stmt_set= , > > - tree out_type, stmt_vec_info stmt_info) > > + tree out_type, stmt_vec_info stmt_info, > > + bool type_only =3D false) > > { > > /* Gather original stmts in the bool pattern in their order of appea= rance > > in the IL. */ > > @@ -5523,16 +5548,16 @@ adjust_bool_stmts (vec_info *vinfo, hash_set > &bool_stmt_set, > > bool_stmts.quick_push (*i); > > bool_stmts.qsort (sort_after_uid); > > > > + gimple *last_stmt =3D NULL; > > + > > /* Now process them in that order, producing pattern stmts. */ > > hash_map defs; > > - for (unsigned i =3D 0; i < bool_stmts.length (); ++i) > > - adjust_bool_pattern (vinfo, gimple_assign_lhs (bool_stmts[i]), > > - out_type, stmt_info, defs); > > + for (auto bool_stmt : bool_stmts) > > + adjust_bool_pattern (vinfo, gimple_assign_lhs (bool_stmt), > > + out_type, stmt_info, defs, last_stmt, type_only); > > > > /* Pop the last pattern seq stmt and install it as pattern root for = STMT. */ > > - gimple *pattern_stmt > > - =3D gimple_seq_last_stmt (STMT_VINFO_PATTERN_DEF_SEQ (stmt_info)); > > - return gimple_assign_lhs (pattern_stmt); > > + return gimple_assign_lhs (last_stmt); > > } > > > > /* Return the proper type for converting bool VAR into > > @@ -5608,13 +5633,27 @@ vect_recog_bool_pattern (vec_info *vinfo, > > enum tree_code rhs_code; > > tree var, lhs, rhs, vectype; > > gimple *pattern_stmt; > > - > > - if (!is_gimple_assign (last_stmt)) > > + gcond* cond =3D NULL; > > + if (!is_gimple_assign (last_stmt) > > + && !(cond =3D dyn_cast (last_stmt))) > > return NULL; > > > > - var =3D gimple_assign_rhs1 (last_stmt); > > - lhs =3D gimple_assign_lhs (last_stmt); > > - rhs_code =3D gimple_assign_rhs_code (last_stmt); > > + loop_vec_info loop_vinfo =3D dyn_cast (vinfo); > > + if (is_gimple_assign (last_stmt)) > > + { > > + var =3D gimple_assign_rhs1 (last_stmt); > > + lhs =3D gimple_assign_lhs (last_stmt); > > + rhs_code =3D gimple_assign_rhs_code (last_stmt); > > + } > > + else if (loop_vinfo && LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) > > + { > > + /* If not multiple exits, and loop vectorization don't bother an= alyzing > > + the gcond as we don't support SLP today. */ > > + lhs =3D var =3D gimple_cond_lhs (last_stmt); > > + rhs_code =3D gimple_cond_code (last_stmt); > > + } > > + else > > + return NULL; > > > > if (rhs_code =3D=3D VIEW_CONVERT_EXPR) > > var =3D TREE_OPERAND (var, 0); > > @@ -5632,7 +5671,7 @@ vect_recog_bool_pattern (vec_info *vinfo, > > return NULL; > > vectype =3D get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs))= ; > > > > - if (check_bool_pattern (var, vinfo, bool_stmts)) > > + if (check_bool_pattern (var, vinfo, bool_stmts, false)) > > { > > rhs =3D adjust_bool_stmts (vinfo, bool_stmts, > > TREE_TYPE (lhs), stmt_vinfo); > > @@ -5680,7 +5719,7 @@ vect_recog_bool_pattern (vec_info *vinfo, > > > > return pattern_stmt; > > } > > - else if (rhs_code =3D=3D COND_EXPR > > + else if ((rhs_code =3D=3D COND_EXPR || cond) > > && TREE_CODE (var) =3D=3D SSA_NAME) > > { > > vectype =3D get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs))= ; > > @@ -5700,18 +5739,31 @@ vect_recog_bool_pattern (vec_info *vinfo, > > if (get_vectype_for_scalar_type (vinfo, type) =3D=3D NULL_TREE) > > return NULL; > > > > - if (check_bool_pattern (var, vinfo, bool_stmts)) > > - var =3D adjust_bool_stmts (vinfo, bool_stmts, type, stmt_vinfo); > > + if (check_bool_pattern (var, vinfo, bool_stmts, cond)) > > + var =3D adjust_bool_stmts (vinfo, bool_stmts, type, stmt_vinfo, cond)= ; > > else if (integer_type_for_mask (var, vinfo)) > > return NULL; > > > > - lhs =3D vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL); > > - pattern_stmt > > - =3D gimple_build_assign (lhs, COND_EXPR, > > - build2 (NE_EXPR, boolean_type_node, > > - var, build_int_cst (TREE_TYPE (var), 0)), > > - gimple_assign_rhs2 (last_stmt), > > - gimple_assign_rhs3 (last_stmt)); > > + if (!cond) > > + { > > + lhs =3D vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL); > > + pattern_stmt > > + =3D gimple_build_assign (lhs, COND_EXPR, > > + build2 (NE_EXPR, boolean_type_node, var, > > + build_int_cst (TREE_TYPE (var), 0)), > > + gimple_assign_rhs2 (last_stmt), > > + gimple_assign_rhs3 (last_stmt)); > > + } > > + else > > + { > > + pattern_stmt > > + =3D gimple_build_cond (gimple_cond_code (cond), > > + gimple_cond_lhs (cond), gimple_cond_rhs (cond), > > + gimple_cond_true_label (cond), > > + gimple_cond_false_label (cond)); > > + vectype =3D get_vectype_for_scalar_type (vinfo, TREE_TYPE (var)); > > + vectype =3D truth_type_for (vectype); > > + } > > *type_out =3D vectype; > > vect_pattern_detected ("vect_recog_bool_pattern", last_stmt); > > >=20 > So this is also quite odd. You're hooking into COND_EXPR handling > but only look at the LHS of the GIMPLE_COND compare. >=20 Hmm, not sure I follow, GIMPLE_CONDs don't have an LHS no? we look at the L= HS For the COND_EXPR but a GCOND we just recreate the statement and set vectyp= e based on the updated var. I guess this is related to: > that we if-converted. We need to recognize that _1, _2 and _3 have > mask uses and thus possibly adjust them. Which I did think about somewhat, so what you're saying is that I need to c= reate a new GIMPLE_COND here with an NE to 0 compare against var like the COND_EX= PR case? > Please refactor the changes to separate the GIMPLE_COND path > completely. >=20 Ok, then it seems better to make two patterns? > Is there test coverage for such "complex" condition? I think > you'll need adjustments to vect_recog_mask_conversion_pattern > as well similar as to how COND_EXPR is handled there. Yes, the existing testsuite has many cases which fail, including gcc/testsu= ite/gcc.c-torture/execute/20150611-1.c Cheers, Tamar >=20 > > @@ -5725,7 +5777,7 @@ vect_recog_bool_pattern (vec_info *vinfo, > > if (!vectype || !VECTOR_MODE_P (TYPE_MODE (vectype))) > > return NULL; > > > > - if (check_bool_pattern (var, vinfo, bool_stmts)) > > + if (check_bool_pattern (var, vinfo, bool_stmts, false)) > > rhs =3D adjust_bool_stmts (vinfo, bool_stmts, > > TREE_TYPE (vectype), stmt_vinfo); > > else > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > > index > 582c5e678fad802d6e76300fe3c939b9f2978f17..e9116d184149826ba436b0f5 > 62721c140d586c94 100644 > > --- a/gcc/tree-vect-stmts.cc > > +++ b/gcc/tree-vect-stmts.cc > > @@ -12489,7 +12489,7 @@ vectorizable_comparison_1 (vec_info *vinfo, tre= e > vectype, > > vec vec_oprnds0 =3D vNULL; > > vec vec_oprnds1 =3D vNULL; > > tree mask_type; > > - tree mask; > > + tree mask =3D NULL_TREE; > > > > if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) > > return false; > > @@ -12629,8 +12629,9 @@ vectorizable_comparison_1 (vec_info *vinfo, tre= e > vectype, > > /* Transform. */ > > > > /* Handle def. */ > > - lhs =3D gimple_assign_lhs (STMT_VINFO_STMT (stmt_info)); > > - mask =3D vect_create_destination_var (lhs, mask_type); > > + lhs =3D gimple_get_lhs (STMT_VINFO_STMT (stmt_info)); > > + if (lhs) > > + mask =3D vect_create_destination_var (lhs, mask_type); > > > > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > > rhs1, &vec_oprnds0, vectype, > > @@ -12644,7 +12645,10 @@ vectorizable_comparison_1 (vec_info *vinfo, tr= ee > vectype, > > gimple *new_stmt; > > vec_rhs2 =3D vec_oprnds1[i]; > > > > - new_temp =3D make_ssa_name (mask); > > + if (lhs) > > + new_temp =3D make_ssa_name (mask); > > + else > > + new_temp =3D make_temp_ssa_name (mask_type, NULL, "cmp"); > > if (bitop1 =3D=3D NOP_EXPR) > > { > > new_stmt =3D gimple_build_assign (new_temp, code, > > @@ -12723,6 +12727,184 @@ vectorizable_comparison (vec_info *vinfo, > > return true; > > } > > > > +/* Check to see if the current early break given in STMT_INFO is valid= for > > + vectorization. */ > > + > > +static bool > > +vectorizable_early_exit (vec_info *vinfo, stmt_vec_info stmt_info, > > + gimple_stmt_iterator *gsi, gimple **vec_stmt, > > + slp_tree slp_node, stmt_vector_for_cost *cost_vec) > > +{ > > + loop_vec_info loop_vinfo =3D dyn_cast (vinfo); > > + if (!loop_vinfo > > + || !is_a (STMT_VINFO_STMT (stmt_info))) > > + return false; > > + > > + if (STMT_VINFO_DEF_TYPE (stmt_info) !=3D vect_condition_def) > > + return false; > > + > > + if (!STMT_VINFO_RELEVANT_P (stmt_info)) > > + return false; > > + > > + auto code =3D gimple_cond_code (STMT_VINFO_STMT (stmt_info)); > > + tree vectype =3D STMT_VINFO_VECTYPE (stmt_info); > > + gcc_assert (vectype); > > + > > + tree vectype_op0 =3D NULL_TREE; > > + slp_tree slp_op0; > > + tree op0; > > + enum vect_def_type dt0; > > + if (!vect_is_simple_use (vinfo, stmt_info, slp_node, 0, &op0, &slp_o= p0, &dt0, > > + &vectype_op0)) > > + { > > + if (dump_enabled_p ()) > > + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > > + "use not simple.\n"); > > + return false; > > + } >=20 > I think you rely on patterns transforming this into canonical form > mask !=3D 0, so I suggest to check this here. >=20 > > + machine_mode mode =3D TYPE_MODE (vectype); > > + int ncopies; > > + > > + if (slp_node) > > + ncopies =3D 1; > > + else > > + ncopies =3D vect_get_num_copies (loop_vinfo, vectype); > > + > > + vec_loop_masks *masks =3D &LOOP_VINFO_MASKS (loop_vinfo); > > + bool masked_loop_p =3D LOOP_VINFO_FULLY_MASKED_P (loop_vinfo); > > + > > + /* Analyze only. */ > > + if (!vec_stmt) > > + { > > + if (direct_optab_handler (cbranch_optab, mode) =3D=3D CODE_FOR_n= othing) > > + { > > + if (dump_enabled_p ()) > > + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > > + "can't vectorize early exit because the " > > + "target doesn't support flag setting vector " > > + "comparisons.\n"); > > + return false; > > + } > > + > > + if (ncopies > 1 >=20 > Also required for vec_num > 1 with SLP > (SLP_TREE_NUMBER_OF_VEC_STMTS) >=20 > > + && direct_optab_handler (ior_optab, mode) =3D=3D CODE_FOR_nothing) > > + { > > + if (dump_enabled_p ()) > > + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > > + "can't vectorize early exit because the " > > + "target does not support boolean vector OR for " > > + "type %T.\n", vectype); > > + return false; > > + } > > + > > + if (!vectorizable_comparison_1 (vinfo, vectype, stmt_info, code,= gsi, > > + vec_stmt, slp_node, cost_vec)) > > + return false; > > + > > + if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)) > > + { > > + if (direct_internal_fn_supported_p (IFN_VCOND_MASK_LEN, vectype, > > + OPTIMIZE_FOR_SPEED)) > > + return false; > > + else > > + vect_record_loop_mask (loop_vinfo, masks, ncopies, vectype, NULL)= ; > > + } > > + > > + > > + return true; > > + } > > + > > + /* Tranform. */ > > + > > + tree new_temp =3D NULL_TREE; > > + gimple *new_stmt =3D NULL; > > + > > + if (dump_enabled_p ()) > > + dump_printf_loc (MSG_NOTE, vect_location, "transform early-exit.\n= "); > > + > > + if (!vectorizable_comparison_1 (vinfo, vectype, stmt_info, code, gsi= , > > + vec_stmt, slp_node, cost_vec)) > > + gcc_unreachable (); > > + > > + gimple *stmt =3D STMT_VINFO_STMT (stmt_info); > > + basic_block cond_bb =3D gimple_bb (stmt); > > + gimple_stmt_iterator cond_gsi =3D gsi_last_bb (cond_bb); > > + > > + auto_vec stmts; > > + > > + tree mask =3D NULL_TREE; > > + if (masked_loop_p) > > + mask =3D vect_get_loop_mask (loop_vinfo, gsi, masks, ncopies, vect= ype, 0); > > + > > + if (slp_node) > > + stmts.safe_splice (SLP_TREE_VEC_DEFS (slp_node)); > > + else > > + { > > + auto vec_stmts =3D STMT_VINFO_VEC_STMTS (stmt_info); > > + stmts.reserve_exact (vec_stmts.length ()); > > + for (auto stmt : vec_stmts) > > + stmts.quick_push (gimple_assign_lhs (stmt)); > > + } > > + > > + /* Determine if we need to reduce the final value. */ > > + if (stmts.length () > 1) > > + { > > + /* We build the reductions in a way to maintain as much parallel= ism as > > + possible. */ > > + auto_vec workset (stmts.length ()); > > + > > + /* Mask the statements as we queue them up. */ > > + if (masked_loop_p) > > + for (auto stmt : stmts) > > + workset.quick_push (prepare_vec_mask (loop_vinfo, TREE_TYPE (mask), > > + mask, stmt, &cond_gsi)); >=20 > I think this still uses the wrong mask, you need to use >=20 > vect_get_loop_mask (loop_vinfo, gsi, masks, ncopies, vectype, ) >=20 > replacing with the vector def index to mask I think. For this > reason keeping the "final" mask below is also wrong. >=20 > Or am I missing something? >=20 > > + else > > + workset.splice (stmts); > > + > > + while (workset.length () > 1) > > + { > > + new_temp =3D make_temp_ssa_name (vectype, NULL, "vexit_reduc"); > > + tree arg0 =3D workset.pop (); > > + tree arg1 =3D workset.pop (); > > + new_stmt =3D gimple_build_assign (new_temp, BIT_IOR_EXPR, arg0, arg= 1); > > + vect_finish_stmt_generation (loop_vinfo, stmt_info, new_stmt, > > + &cond_gsi); > > + workset.quick_insert (0, new_temp); > > + } > > + } > > + else > > + new_temp =3D stmts[0]; > > + > > + gcc_assert (new_temp); > > + > > + tree cond =3D new_temp; > > + /* If we have multiple statements after reduction we should check al= l the > > + lanes and treat it as a full vector. */ > > + if (masked_loop_p) > > + cond =3D prepare_vec_mask (loop_vinfo, TREE_TYPE (mask), mask, con= d, > > + &cond_gsi); >=20 > so just do this in the else path above >=20 > Otherwise looks OK. >=20 > Richard. >=20 > > + /* Now build the new conditional. Pattern gimple_conds get dropped = during > > + codegen so we must replace the original insn. */ > > + stmt =3D STMT_VINFO_STMT (vect_orig_stmt (stmt_info)); > > + gcond *cond_stmt =3D as_a (stmt); > > + gimple_cond_set_condition (cond_stmt, NE_EXPR, cond, > > + build_zero_cst (vectype)); > > + update_stmt (stmt); > > + > > + if (slp_node) > > + SLP_TREE_VEC_DEFS (slp_node).truncate (0); > > + else > > + STMT_VINFO_VEC_STMTS (stmt_info).truncate (0); > > + > > + > > + if (!slp_node) > > + *vec_stmt =3D stmt; > > + > > + return true; > > +} > > + > > /* If SLP_NODE is nonnull, return true if vectorizable_live_operation > > can handle all live statements in the node. Otherwise return true > > if STMT_INFO is not live or if vectorizable_live_operation can hand= le it. > > @@ -12949,7 +13131,9 @@ vect_analyze_stmt (vec_info *vinfo, > > || vectorizable_lc_phi (as_a (vinfo), > > stmt_info, NULL, node) > > || vectorizable_recurr (as_a (vinfo), > > - stmt_info, NULL, node, cost_vec)); > > + stmt_info, NULL, node, cost_vec) > > + || vectorizable_early_exit (vinfo, stmt_info, NULL, NULL, node, > > + cost_vec)); > > else > > { > > if (bb_vinfo) > > @@ -12972,7 +13156,10 @@ vect_analyze_stmt (vec_info *vinfo, > > NULL, NULL, node, cost_vec) > > || vectorizable_comparison (vinfo, stmt_info, NULL, NULL, node, > > cost_vec) > > - || vectorizable_phi (vinfo, stmt_info, NULL, node, cost_vec)); > > + || vectorizable_phi (vinfo, stmt_info, NULL, node, cost_vec) > > + || vectorizable_early_exit (vinfo, stmt_info, NULL, NULL, node, > > + cost_vec)); > > + > > } > > > > if (node) > > @@ -13131,6 +13318,12 @@ vect_transform_stmt (vec_info *vinfo, > > gcc_assert (done); > > break; > > > > + case loop_exit_ctrl_vec_info_type: > > + done =3D vectorizable_early_exit (vinfo, stmt_info, gsi, &vec_st= mt, > > + slp_node, NULL); > > + gcc_assert (done); > > + break; > > + > > default: > > if (!STMT_VINFO_LIVE_P (stmt_info)) > > { > > @@ -14321,10 +14514,19 @@ vect_get_vector_types_for_stmt (vec_info > *vinfo, stmt_vec_info stmt_info, > > } > > else > > { > > + gcond *cond =3D NULL; > > if (data_reference *dr =3D STMT_VINFO_DATA_REF (stmt_info)) > > scalar_type =3D TREE_TYPE (DR_REF (dr)); > > else if (gimple_call_internal_p (stmt, IFN_MASK_STORE)) > > scalar_type =3D TREE_TYPE (gimple_call_arg (stmt, 3)); > > + else if ((cond =3D dyn_cast (stmt))) > > + { > > + /* We can't convert the scalar type to boolean yet, since booleans = have a > > + single bit precision and we need the vector boolean to be a > > + representation of the integer mask. So set the correct integer = type and > > + convert to boolean vector once we have a vectype. */ > > + scalar_type =3D TREE_TYPE (gimple_cond_lhs (cond)); > > + } > > else > > scalar_type =3D TREE_TYPE (gimple_get_lhs (stmt)); > > > > @@ -14339,12 +14541,18 @@ vect_get_vector_types_for_stmt (vec_info > *vinfo, stmt_vec_info stmt_info, > > "get vectype for scalar type: %T\n", scalar_type); > > } > > vectype =3D get_vectype_for_scalar_type (vinfo, scalar_type, gro= up_size); > > + > > if (!vectype) > > return opt_result::failure_at (stmt, > > "not vectorized:" > > " unsupported data-type %T\n", > > scalar_type); > > > > + /* If we were a gcond, convert the resulting type to a vector bo= olean type > now > > + that we have the correct integer mask type. */ > > + if (cond) > > + vectype =3D truth_type_for (vectype); > > + > > if (dump_enabled_p ()) > > dump_printf_loc (MSG_NOTE, vect_location, "vectype: %T\n", vectype); > > } > > >=20 > -- > Richard Biener > SUSE Software Solutions Germany GmbH, > Frankenstrasse 146, 90461 Nuernberg, Germany; > GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg= )