From patchwork Wed May 4 09:25:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 93995 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]) by ozlabs.org (Postfix) with SMTP id AFDF9B6F70 for ; Wed, 4 May 2011 19:26:13 +1000 (EST) Received: (qmail 21581 invoked by alias); 4 May 2011 09:26:11 -0000 Received: (qmail 21559 invoked by uid 22791); 4 May 2011 09:26:10 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, TW_ZJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 May 2011 09:25:53 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p449PqPX030354 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 4 May 2011 05:25:52 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p449Pqlf004092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 4 May 2011 05:25:52 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p449Pp5Z032687 for ; Wed, 4 May 2011 11:25:51 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p449Pp0H032685 for gcc-patches@gcc.gnu.org; Wed, 4 May 2011 11:25:51 +0200 Date: Wed, 4 May 2011 11:25:51 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: Some backports from mainline to gcc 4.4 branch Message-ID: <20110504092551.GC17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! And here are 3 backports to 4.4 branch, bootstrapped/regtested on x86_64-linux and i686-linux, committed to gcc-4_4-branch. Jakub 2011-05-04 Jakub Jelinek Backported from mainline 2011-05-03 Uros Bizjak Jakub Jelinek PR target/48774 * config/i386/i386.c (ix86_match_ccmode): For CC{A,C,O,S}mode only succeed if req_mode is the same as set_mode. * gcc.dg/pr48774.c: New test. 2011-05-04 Jakub Jelinek Backport from mainline 2011-04-30 Jakub Jelinek PR tree-optimization/48809 * tree-switch-conversion.c (build_arrays): Compute tidx in unsigned type. (gen_inbound_check): Don't compute index_expr - range_min in utype again, instead reuse SSA_NAME initialized in build_arrays. Remove two useless gsi_for_stmt calls. * gcc.c-torture/execute/pr48809.c: New test. --- gcc/tree-switch-conversion.c (revision 173206) +++ gcc/tree-switch-conversion.c (revision 173207) @@ -519,7 +519,7 @@ static void build_arrays (gimple swtch) { tree arr_index_type; - tree tidx, sub; + tree tidx, sub, utype; gimple stmt; gimple_stmt_iterator gsi; int i; @@ -527,12 +527,20 @@ build_arrays (gimple swtch) gsi = gsi_for_stmt (swtch); arr_index_type = build_index_type (info.range_size); - tidx = make_rename_temp (arr_index_type, "csti"); - sub = fold_build2 (MINUS_EXPR, TREE_TYPE (info.index_expr), info.index_expr, - fold_convert (TREE_TYPE (info.index_expr), - info.range_min)); - sub = force_gimple_operand_gsi (&gsi, fold_convert (arr_index_type, sub), - false, NULL, true, GSI_SAME_STMT); + + /* Make sure we do not generate arithmetics in a subrange. */ + if (TREE_TYPE (TREE_TYPE (info.index_expr))) + utype = lang_hooks.types.type_for_mode + (TYPE_MODE (TREE_TYPE (TREE_TYPE (info.index_expr))), 1); + else + utype = lang_hooks.types.type_for_mode + (TYPE_MODE (TREE_TYPE (info.index_expr)), 1); + + tidx = make_rename_temp (utype, "csui"); + sub = fold_build2 (MINUS_EXPR, utype, + fold_convert (utype, info.index_expr), + fold_convert (utype, info.range_min)); + sub = force_gimple_operand_gsi (&gsi, sub, false, NULL, true, GSI_SAME_STMT); stmt = gimple_build_assign (tidx, sub); gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); @@ -641,10 +649,7 @@ gen_inbound_check (gimple swtch) gimple label1, label2, label3; tree utype; - tree tmp_u; - tree cast; - gimple cast_assign, minus_assign; - tree ulb, minus; + tree tidx; tree bound; gimple cond_stmt; @@ -657,49 +662,27 @@ gen_inbound_check (gimple swtch) gcc_assert (info.default_values); bb0 = gimple_bb (swtch); - /* Make sure we do not generate arithmetics in a subrange. */ - if (TREE_TYPE (TREE_TYPE (info.index_expr))) - utype = lang_hooks.types.type_for_mode - (TYPE_MODE (TREE_TYPE (TREE_TYPE (info.index_expr))), 1); - else - utype = lang_hooks.types.type_for_mode - (TYPE_MODE (TREE_TYPE (info.index_expr)), 1); + tidx = gimple_assign_lhs (info.arr_ref_first); + utype = TREE_TYPE (tidx); /* (end of) block 0 */ gsi = gsi_for_stmt (info.arr_ref_first); - tmp_u = make_rename_temp (utype, "csui"); - - cast = fold_convert (utype, info.index_expr); - cast_assign = gimple_build_assign (tmp_u, cast); - find_new_referenced_vars (cast_assign); - gsi_insert_before (&gsi, cast_assign, GSI_SAME_STMT); - mark_symbols_for_renaming (cast_assign); - - ulb = fold_convert (utype, info.range_min); - minus = fold_build2 (MINUS_EXPR, utype, tmp_u, ulb); - minus = force_gimple_operand_gsi (&gsi, minus, false, NULL, true, - GSI_SAME_STMT); - minus_assign = gimple_build_assign (tmp_u, minus); - find_new_referenced_vars (minus_assign); - gsi_insert_before (&gsi, minus_assign, GSI_SAME_STMT); - mark_symbols_for_renaming (minus_assign); + gsi_next (&gsi); bound = fold_convert (utype, info.range_size); - cond_stmt = gimple_build_cond (LE_EXPR, tmp_u, bound, NULL_TREE, NULL_TREE); + cond_stmt = gimple_build_cond (LE_EXPR, tidx, bound, NULL_TREE, NULL_TREE); find_new_referenced_vars (cond_stmt); gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT); mark_symbols_for_renaming (cond_stmt); /* block 2 */ - gsi = gsi_for_stmt (info.arr_ref_first); label2 = gimple_build_label (label_decl2); gsi_insert_before (&gsi, label2, GSI_SAME_STMT); last_assign = gen_def_assigns (&gsi); /* block 1 */ - gsi = gsi_for_stmt (info.arr_ref_first); label1 = gimple_build_label (label_decl1); gsi_insert_before (&gsi, label1, GSI_SAME_STMT); --- gcc/testsuite/gcc.c-torture/execute/pr48809.c (revision 0) +++ gcc/testsuite/gcc.c-torture/execute/pr48809.c (revision 173207) @@ -0,0 +1,60 @@ +/* PR tree-optimization/48809 */ + +extern void abort (void); + +int +foo (signed char x) +{ + int y = 0; + switch (x) + { + case 0: y = 1; break; + case 1: y = 7; break; + case 2: y = 2; break; + case 3: y = 19; break; + case 4: y = 5; break; + case 5: y = 17; break; + case 6: y = 31; break; + case 7: y = 8; break; + case 8: y = 28; break; + case 9: y = 16; break; + case 10: y = 31; break; + case 11: y = 12; break; + case 12: y = 15; break; + case 13: y = 111; break; + case 14: y = 17; break; + case 15: y = 10; break; + case 16: y = 31; break; + case 17: y = 7; break; + case 18: y = 2; break; + case 19: y = 19; break; + case 20: y = 5; break; + case 21: y = 107; break; + case 22: y = 31; break; + case 23: y = 8; break; + case 24: y = 28; break; + case 25: y = 106; break; + case 26: y = 31; break; + case 27: y = 102; break; + case 28: y = 105; break; + case 29: y = 111; break; + case 30: y = 17; break; + case 31: y = 10; break; + case 32: y = 31; break; + case 98: y = 18; break; + case -62: y = 19; break; + } + return y; +} + +int +main () +{ + if (foo (98) != 18 || foo (97) != 0 || foo (99) != 0) + abort (); + if (foo (-62) != 19 || foo (-63) != 0 || foo (-61) != 0) + abort (); + if (foo (28) != 105 || foo (27) != 102 || foo (29) != 111) + abort (); + return 0; +} 2011-05-04 Jakub Jelinek Backport from mainline 2011-04-28 Jakub Jelinek PR middle-end/48597 * final.c (final_scan_insn): Call dwarf2out_frame_debug even for inline asm. --- gcc/final.c (revision 173119) +++ gcc/final.c (revision 173120) @@ -2313,6 +2313,11 @@ final_scan_insn (rtx insn, FILE *file, i location_t loc; expanded_location expanded; + /* Make sure we flush any queued register saves in case this + clobbers affected registers. */ + if (dwarf2out_do_frame ()) + dwarf2out_frame_debug (insn, false); + /* There's no telling what that did to the condition codes. */ CC_STATUS_INIT; --- gcc/config/i386/i386.c (revision 173300) +++ gcc/config/i386/i386.c (revision 173301) @@ -17299,11 +17299,15 @@ ix86_match_ccmode (rtx insn, enum machin if (req_mode == CCZmode) return 0; /* FALLTHRU */ + case CCZmode: + break; + case CCAmode: case CCCmode: case CCOmode: case CCSmode: - case CCZmode: + if (set_mode != req_mode) + return 0; break; default: --- gcc/testsuite/gcc.dg/pr48774.c (revision 0) +++ gcc/testsuite/gcc.dg/pr48774.c (revision 173301) @@ -0,0 +1,38 @@ +/* PR target/48774 */ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void abort (void); +unsigned long int s[24] + = { 12, ~1, 12, ~2, 12, ~4, 12, ~8, 12, ~16, 12, ~32, + 12, ~64, 12, ~128, 12, ~256, 12, ~512, 12, ~1024, 12, ~2048 }; +struct { int n; unsigned long *e[12]; } g + = { 12, { &s[0], &s[2], &s[4], &s[6], &s[8], &s[10], &s[12], &s[14], + &s[16], &s[18], &s[20], &s[22] } }; +int c[12]; + +__attribute__((noinline)) void +foo (void) +{ + int i, j; + for (i = 0; i < g.n; i++) + for (j = 0; j < g.n; j++) + { + if (i == j && j < g.e[0][0] && (g.e[i][1] & (1UL << j))) + abort (); + if (j < g.e[0][0] && (g.e[i][1] & (1UL << j))) + c[i]++; + } +} + +int +main () +{ + int i; + asm volatile ("" : "+m" (s), "+m" (g), "+m" (c)); + foo (); + for (i = 0; i < 12; i++) + if (c[i] != 11) + abort (); + return 0; +}