From patchwork Mon Aug 11 07:11:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Gareev X-Patchwork-Id: 378894 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 3EF1414013B for ; Mon, 11 Aug 2014 17:11:48 +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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=WqQtcWA/v5dD3V5VOp fiVppHQwbV90TUyqeuToB48x1pu4DXVuqsbi09PlJZVsOggrVcvvezsqTmm6tNiu cjxgnlAx+gktVXqYWtAHavYY5k0JnTu2mD+99wZ+H+m5glP+n3Xckktrs1bOcIOz B6sxd0Hs5cr3l8+sKZAEJfpUI= 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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=nnp475OD3KQqkZe726z5XBkV ys0=; b=Rk7AHb+Nadl3ZTSeRqYR3pIlugeWFsxTaxBq0PgxKAqMG0shai5N1+Md Przzjcg21KJNKOkX5ED1HFe6XGvPnvCkZ/I8QHITiE7AqjqaX57QFuf4m2h2xNXM HLs7yC5ytTtQS+G37HRyGVMDZwUk0HrRzjbxXgCyPmFJDUlPCLU= Received: (qmail 3318 invoked by alias); 11 Aug 2014 07:11:42 -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 3305 invoked by uid 89); 11 Aug 2014 07:11:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f170.google.com Received: from mail-yk0-f170.google.com (HELO mail-yk0-f170.google.com) (209.85.160.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 11 Aug 2014 07:11:39 +0000 Received: by mail-yk0-f170.google.com with SMTP id 9so5651872ykp.15 for ; Mon, 11 Aug 2014 00:11:37 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.236.53.163 with SMTP id g23mr40172054yhc.15.1407741097378; Mon, 11 Aug 2014 00:11:37 -0700 (PDT) Received: by 10.170.85.194 with HTTP; Mon, 11 Aug 2014 00:11:37 -0700 (PDT) In-Reply-To: <53E86219.6010904@grosser.es> References: <53E24E47.2090803@grosser.es> <53E3806E.7040903@grosser.es> <53E4CD87.5080105@grosser.es> <53E5D33C.6050800@grosser.es> <53E86219.6010904@grosser.es> Date: Mon, 11 Aug 2014 13:11:37 +0600 Message-ID: Subject: Re: [GSoC] Elimination of CLooG library installation dependency From: Roman Gareev To: Tobias Grosser Cc: Mircea Namolaru , gcc-patches@gcc.gnu.org > I am confused. It seems you attached some kind of reduced version of > btCollisionWorld.cpp? How did you obtain it? Did you compile and test > with these versions? I’ve manually selected parts of code, which produce the scope. I’ve found out that this bug is most probably caused by absence of pointer handling. The tree, which is corresponding to P_11 has pointer type. Furthermore, if we consider the transformed gimple code for (it can be found attached), we’ll see that it contains wrong parts: The code produced by modified version of Graphite: ... _35 = (signed long) _11; _36 = _34 + _35; _37 = _36 % 0; _38 = _37 > 0; _39 = (signed long) _38; ... The code produced by origin version of Graphite: ... _36 = (sizetype) _11; _37 = _36 + 18446744073709551615; _38 = 8B + _37; _39 = _38 % 0B; _40 = _39 != -1B; ... (If I’m not mistaken, 0B, for example, corresponds to (void *). It can be seen here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50712) I’ve tried to implement pointer handling in the attached patch, but it is wrong. I get the following error instead of seagfault now: Floating point exception (core dumped) back trace: Program terminated with signal 8, Arithmetic exception. #0 0x00000000004204c5 in allocSize (this=, size=) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/include/LinearMath/btAlignedObjectArray.h:59 59 return (size ? size*2 : 1); (gdb) bt #0 0x00000000004204c5 in allocSize (this=, size=) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/include/LinearMath/btAlignedObjectArray.h:59 #1 push_back (_Val=, this=0x1125600) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/include/LinearMath/btAlignedObjectArray.h:220 #2 btCollisionDispatcher::getNewManifold (this=0x11255f0, b0=, b1=) at btCollisionDispatcher.llvm.cpp:100 #3 0x000000000044e764 in btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm (this=0x7f665ca6b0c0, mf=0x0, ci=..., col0=, col1=, isSwapped=, numPerturbationIterations=1, minimumPointsPerturbationThreshold=1) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/btConvexPlaneCollisionAlgorithm.cpp:38 #4 0x000000000046281b in btConvexPlaneCollisionAlgorithm::CreateFunc::CreateCollisionAlgorithm (this=0x11254e0, ci=..., body0=0x113d040, body1=0x113d810) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/include/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h:76 #5 0x00000000004205ac in btCollisionDispatcher::findAlgorithm ( this=, body0=, body1=, sharedManifold=) at btCollisionDispatcher.llvm.cpp:145 #6 0x00000000004202e2 in btCollisionDispatcher::defaultNearCallback ( ---Type to continue, or q to quit--- collisionPair=..., dispatcher=..., dispatchInfo=...) at btCollisionDispatcher.llvm.cpp:258 #7 0x000000000042083b in btCollisionPairCallback::processOverlap ( this=, pair=...) at btCollisionDispatcher.llvm.cpp:224 #8 0x00000000004acff2 in btHashedOverlappingPairCache::processAllOverlappingPairs (this=0x1127f80, callback=0x7fff0d1af790, dispatcher=0x11255f0) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/btOverlappingPairCache.cpp:387 #9 0x00000000004200c9 in btCollisionDispatcher::dispatchAllCollisionPairs ( this=, pairCache=, dispatchInfo=..., dispatcher=) at btCollisionDispatcher.llvm.cpp:238 #10 0x0000000000421bd4 in btCollisionWorld::performDiscreteCollisionDetection() () #11 0x0000000000464d9a in btDiscreteDynamicsWorld::internalSingleStepSimulation(float) () #12 0x000000000046473f in btDiscreteDynamicsWorld::stepSimulation(float, int, float) () #13 0x0000000000401e08 in BenchmarkDemo::clientMoveAndDisplay ( this=0x7fff0d1af980) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/BenchmarkDemo.cpp:232 #14 0x0000000000401b12 in main (argc=, argv=) at /home/roman/llvm-test-suite/MultiSource/Benchmarks/Bullet/main.cpp:63 Could you please advise me an algorithm for pointer handling? Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 213774) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -150,6 +150,8 @@ gcc_assert (res != ip.end () && "Could not map isl_id to tree expression"); isl_ast_expr_free (expr_id); + if (POINTER_TYPE_P (TREE_TYPE (res->second))) + return res->second; return fold_convert (type, res->second); } @@ -178,18 +180,46 @@ type TYPE. */ static tree -binary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip) +binary_op_to_tree (tree recommended_type, __isl_take isl_ast_expr *expr, + ivs_params &ip) { isl_ast_expr *arg_expr = isl_ast_expr_get_op_arg (expr, 0); - tree tree_lhs_expr = gcc_expression_from_isl_expression (type, arg_expr, ip); + tree tree_lhs_expr = + gcc_expression_from_isl_expression (recommended_type, arg_expr, ip); arg_expr = isl_ast_expr_get_op_arg (expr, 1); - tree tree_rhs_expr = gcc_expression_from_isl_expression (type, arg_expr, ip); + tree tree_rhs_expr = + gcc_expression_from_isl_expression (recommended_type, arg_expr, ip); + tree type = POINTER_TYPE_P (TREE_TYPE (tree_lhs_expr)) ? + TREE_TYPE (tree_lhs_expr) : recommended_type; + type = POINTER_TYPE_P (TREE_TYPE (tree_rhs_expr)) ? + TREE_TYPE (tree_rhs_expr) : type; + if (POINTER_TYPE_P (type)) + { + if (isl_ast_expr_get_op_type (expr) == isl_ast_op_add || + isl_ast_expr_get_op_type (expr) == isl_ast_op_mul || + isl_ast_expr_get_op_type (expr) == isl_ast_op_div) + { + if (!POINTER_TYPE_P (TREE_TYPE (tree_lhs_expr))) + tree_lhs_expr = fold_convert (sizetype, tree_lhs_expr); + if (!POINTER_TYPE_P (TREE_TYPE (tree_rhs_expr))) + tree_rhs_expr = fold_convert (sizetype, tree_rhs_expr); + } + else + { + tree_lhs_expr = fold_convert (type, tree_lhs_expr); + tree_rhs_expr = fold_convert (type, tree_rhs_expr); + } + } enum isl_ast_op_type expr_type = isl_ast_expr_get_op_type (expr); isl_ast_expr_free (expr); switch (expr_type) { case isl_ast_op_add: - return fold_build2 (PLUS_EXPR, type, tree_lhs_expr, tree_rhs_expr); + if (POINTER_TYPE_P (type)) + return fold_build2 (POINTER_PLUS_EXPR, type, tree_lhs_expr, + tree_rhs_expr); + else + return fold_build2 (PLUS_EXPR, type, tree_lhs_expr, tree_rhs_expr); case isl_ast_op_sub: return fold_build2 (MINUS_EXPR, type, tree_lhs_expr, tree_rhs_expr); @@ -210,26 +240,32 @@ return fold_build2 (FLOOR_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr); case isl_ast_op_and: - return fold_build2 (TRUTH_ANDIF_EXPR, type, + return fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node, tree_lhs_expr, tree_rhs_expr); case isl_ast_op_or: - return fold_build2 (TRUTH_ORIF_EXPR, type, tree_lhs_expr, tree_rhs_expr); + return fold_build2 (TRUTH_ORIF_EXPR, boolean_type_node, tree_lhs_expr, + tree_rhs_expr); case isl_ast_op_eq: - return fold_build2 (EQ_EXPR, type, tree_lhs_expr, tree_rhs_expr); + return fold_build2 (EQ_EXPR, boolean_type_node, tree_lhs_expr, + tree_rhs_expr); case isl_ast_op_le: - return fold_build2 (LE_EXPR, type, tree_lhs_expr, tree_rhs_expr); + return fold_build2 (LE_EXPR, boolean_type_node, tree_lhs_expr, + tree_rhs_expr); case isl_ast_op_lt: - return fold_build2 (LT_EXPR, type, tree_lhs_expr, tree_rhs_expr); + return fold_build2 (LT_EXPR, boolean_type_node, tree_lhs_expr, + tree_rhs_expr); case isl_ast_op_ge: - return fold_build2 (GE_EXPR, type, tree_lhs_expr, tree_rhs_expr); + return fold_build2 (GE_EXPR, boolean_type_node, tree_lhs_expr, + tree_rhs_expr); case isl_ast_op_gt: - return fold_build2 (GT_EXPR, type, tree_lhs_expr, tree_rhs_expr); + return fold_build2 (GT_EXPR, boolean_type_node, tree_lhs_expr, + tree_rhs_expr); default: gcc_unreachable (); @@ -261,12 +297,16 @@ type TYPE. */ static tree -unary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip) +unary_op_to_tree (tree recommended_type, __isl_take isl_ast_expr *expr, + ivs_params &ip) { gcc_assert (isl_ast_expr_get_op_type (expr) == isl_ast_op_minus); isl_ast_expr *arg_expr = isl_ast_expr_get_op_arg (expr, 0); - tree tree_expr = gcc_expression_from_isl_expression (type, arg_expr, ip); + tree tree_expr = + gcc_expression_from_isl_expression (recommended_type, arg_expr, ip); isl_ast_expr_free (expr); + tree type = POINTER_TYPE_P (TREE_TYPE (tree_expr)) ? + TREE_TYPE (tree_expr) : recommended_type; return fold_build1 (NEGATE_EXPR, type, tree_expr); }