From patchwork Wed Aug 6 14:27:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 377041 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 E5B57140095 for ; Thu, 7 Aug 2014 00:30:40 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=btjB4brmn9fgyXutds31sdTuL2IDkMhC+xT1xy4rnlEczRUNA+/nA j3LUIGhF+oOlSWmpuV09dviy2ADZrczJkv/MnHWN2qtAnPTyC4WUrgYGbVBm/3AX A6WJoBx3MX89xjtes6CHBC4xp9FUIeyCpUP7rI5ey5fxNM5fG/Hyd8= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=t0R0uq8s2Riz3wexG/RoOliv9es=; b=jjEFzt3Ujpt6fc/DD7Ar OLS56Y4Gg5XBf/PU2JUZk0I6y+6cEWlBvogkRpdWD4JHWDBjizgws5v+nC+mIj25 3ZcjzYgdINvELro1f3x4kezP4IDkkxqa4yO3qZYSsWaLDZK4NTj8dTil8q5f5RfI rIg2UfDgs+glcSqwkSbSSZA= Received: (qmail 5764 invoked by alias); 6 Aug 2014 14:30:34 -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 5754 invoked by uid 89); 6 Aug 2014 14:30:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 06 Aug 2014 14:30:30 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 38923ACB4 for ; Wed, 6 Aug 2014 14:30:27 +0000 (UTC) Date: Wed, 6 Aug 2014 16:27:22 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][match-and-simplify] Robusten gimple_build against non-SSA context Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 We fold stmts from non-SSA so when we simplify a single stmt into multiple ones (like strcat (x, "foo") -> memcpy (x + strlen ("foo"), ....)) then gimple_build fails because it unconditionally builds SSA names. Fixed. Richard. 2014-08-06 Richard Biener * gimple-fold.c (gimple_build): Allow to be called from non-SSA context. Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c (revision 213651) +++ gcc/gimple-fold.c (working copy) @@ -3733,7 +3733,10 @@ gimple_build (gimple_seq *seq, location_ tree res = gimple_simplify (code, type, op0, seq, valueize); if (!res) { - res = make_ssa_name (type, NULL); + if (gimple_in_ssa_p (cfun)) + res = make_ssa_name (type, NULL); + else + res = create_tmp_reg (type, NULL); gimple stmt; if (code == REALPART_EXPR || code == IMAGPART_EXPR @@ -3763,7 +3766,10 @@ gimple_build (gimple_seq *seq, location_ tree res = gimple_simplify (code, type, op0, op1, seq, valueize); if (!res) { - res = make_ssa_name (type, NULL); + if (gimple_in_ssa_p (cfun)) + res = make_ssa_name (type, NULL); + else + res = create_tmp_reg (type, NULL); gimple stmt = gimple_build_assign_with_ops (code, res, op0, op1); gimple_set_location (stmt, loc); gimple_seq_add_stmt_without_update (seq, stmt); @@ -3787,7 +3793,10 @@ gimple_build (gimple_seq *seq, location_ seq, valueize); if (!res) { - res = make_ssa_name (type, NULL); + if (gimple_in_ssa_p (cfun)) + res = make_ssa_name (type, NULL); + else + res = create_tmp_reg (type, NULL); gimple stmt; if (code == BIT_FIELD_REF) stmt = gimple_build_assign_with_ops (code, res, @@ -3816,7 +3825,10 @@ gimple_build (gimple_seq *seq, location_ tree res = gimple_simplify (fn, type, arg0, seq, valueize); if (!res) { - res = make_ssa_name (type, NULL); + if (gimple_in_ssa_p (cfun)) + res = make_ssa_name (type, NULL); + else + res = create_tmp_reg (type, NULL); tree decl = builtin_decl_implicit (fn); gimple stmt = gimple_build_call (decl, 1, arg0); gimple_call_set_lhs (stmt, res);