From patchwork Wed Jul 23 14:55:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gareev X-Patchwork-Id: 372986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3DC0F1401A3 for ; Thu, 24 Jul 2014 00:55:21 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=Pgp3ti1nXzgtnOY9p3ml6MQTjQ2lc/ixZLb2Bpg49yj xpl+ESQtIRDag1Wtl+JKxVH3I/3JDXJuB7Xq6NtMDRQq4tOxhjEVNQFnSwP8J0yW QMGoWjA+OAnOJ2XrBldplxTbxbbYmfFanjrvWWX7YkoHCDfxDJ3sHOE5cdXbOTes = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=APFjoxdXrJ2UbXBeca+Z8MVh+K4=; b=hqvazmCfBxem9rBfQ c4r6E5P243XrvSn/2PjPog9KZpThR+z/pz+j+6OVHl2xW9lrOQGrVCHKhBBexie7 iKEdRmgLEvV5e1e7E6DqRP9XOXF2W/kujdrcMiZnnpsL12wSVBWiVkyPWHrvyqV7 e07O++0dzg9RFwehA9zwX81nxY= Received: (qmail 13724 invoked by alias); 23 Jul 2014 14:55:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13702 invoked by uid 89); 23 Jul 2014 14:55:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f49.google.com Received: from mail-yh0-f49.google.com (HELO mail-yh0-f49.google.com) (209.85.213.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 23 Jul 2014 14:55:13 +0000 Received: by mail-yh0-f49.google.com with SMTP id b6so874031yha.36 for ; Wed, 23 Jul 2014 07:55:11 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.236.3.10 with SMTP id 10mr2506278yhg.126.1406127311388; Wed, 23 Jul 2014 07:55:11 -0700 (PDT) Received: by 10.170.91.134 with HTTP; Wed, 23 Jul 2014 07:55:11 -0700 (PDT) Date: Wed, 23 Jul 2014 20:55:11 +0600 Message-ID: Subject: [GSoC] Handling of isl_ast_op_pdiv_q and isl_ast_op_pdiv_r From: Roman Gareev To: Tobias Grosser Cc: Mircea Namolaru , gcc-patches@gcc.gnu.org I've attached the patch, which adds handling of isl_ast_op_pdiv_q and isl_ast_op_pdiv_r. It also contains a corresponding test case, which generates the following ISL AST: { for (int c1 = 0; c1 < -((-k.0 + i + 4294967296) % 4294967296) + 4294967296; c1 += 1) S_4(c1); S_6(); } Is it fine for trunk? --- Cheers, Roman Gareev. 2014-07-23 Roman Gareev [gcc/] * graphite-isl-ast-to-gimple.c: (binary_op_to_tree): Add new cases. (gcc_expression_from_isl_expr_op): Move isl_ast_op_pdiv_q, isl_ast_op_pdiv_r to different cases. [gcc/testsuite] * gcc.dg/graphite/isl-ast-gen-blocks-3.c: New testcase. Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 212922) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -186,6 +186,12 @@ case isl_ast_op_div: return fold_build2 (EXACT_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr); + case isl_ast_op_pdiv_q: + return fold_build2 (TRUNC_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr); + + case isl_ast_op_pdiv_r: + return fold_build2 (TRUNC_MOD_EXPR, type, tree_lhs_expr, tree_rhs_expr); + case isl_ast_op_fdiv_q: return fold_build2 (FLOOR_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr); @@ -299,8 +305,6 @@ case isl_ast_op_call: case isl_ast_op_and_then: case isl_ast_op_or_else: - case isl_ast_op_pdiv_q: - case isl_ast_op_pdiv_r: case isl_ast_op_select: gcc_unreachable (); @@ -312,6 +316,8 @@ case isl_ast_op_sub: case isl_ast_op_mul: case isl_ast_op_div: + case isl_ast_op_pdiv_q: + case isl_ast_op_pdiv_r: case isl_ast_op_fdiv_q: case isl_ast_op_and: case isl_ast_op_or: Index: gcc/testsuite/gcc.dg/graphite/isl-ast-gen-blocks-3.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/isl-ast-gen-blocks-3.c (revision 0) +++ gcc/testsuite/gcc.dg/graphite/isl-ast-gen-blocks-3.c (working copy) @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fgraphite-identity -fgraphite-code-generator=isl" } */ + +int k = 50; +static int __attribute__((noinline)) +foo () +{ + int i, res; + for (i = k/2, res = 0; i < k; i++) + res += i; + + return res; +} + +extern void abort (); + +int +main (void) +{ + int res = foo (); + + + if (res != 925) + abort (); + + return 0; +}