This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][varmap] Preserve bitmaps on SETs in the face of splitters
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Nov 2007 12:23:31 +0100 (CET)
- Subject: [PATCH][varmap] Preserve bitmaps on SETs in the face of splitters
Applied to var-mappings-branch.
Richard.
2007-11-07 Michael Matz <matz@suse.de>
* emit-rtl.c (move_xbitmap): New helper.
(try_split): Preserve bitmap of names from splitters.
* gcc.dg/tree-ssa/vars-2.c: New testcase.
Index: var-mappings-branch/gcc/emit-rtl.c
===================================================================
*** var-mappings-branch.orig/gcc/emit-rtl.c 2007-11-12 17:51:42.000000000 +0100
--- var-mappings-branch/gcc/emit-rtl.c 2007-11-12 17:55:40.000000000 +0100
*************** mark_label_nuses (rtx x)
*** 3185,3190 ****
--- 3185,3204 ----
}
+ static void
+ move_xbitmap (rtx x, const_rtx cset, void *data)
+ {
+ rtx orig_set = (rtx)data;
+ rtx set = (rtx)cset;
+ if (GET_CODE (set) == CLOBBER)
+ return;
+ if (!reg_overlap_mentioned_p (x, SET_DEST (orig_set)))
+ return;
+ if (XBITMAP (set, 2))
+ return;
+ XBITMAP (set, 2) = XBITMAP (orig_set, 2);
+ }
+
/* Try splitting insns that can be split for better scheduling.
PAT is the pattern which might split.
TRIAL is the insn providing PAT.
*************** try_split (rtx pat, rtx trial, int last)
*** 3368,3373 ****
--- 3382,3416 ----
}
}
+ if (GET_CODE (pat) == SET && XBITMAP (pat, 2))
+ {
+ insn = insn_last;
+ while (insn != NULL_RTX)
+ {
+ if (INSN_P (insn))
+ note_stores (PATTERN (insn), move_xbitmap, pat);
+ insn = PREV_INSN (insn);
+ }
+ }
+ else if (GET_CODE (pat) == PARALLEL)
+ {
+ int i;
+ for (i = 0; i < XVECLEN (pat, 0); i++)
+ if (GET_CODE (XVECEXP (pat, 0, i)) == SET
+ && XBITMAP (XVECEXP (pat, 0, i), 2))
+ {
+ rtx set = XVECEXP (pat, 0, i);
+ insn = insn_last;
+ while (insn != NULL_RTX)
+ {
+ if (INSN_P (insn))
+ note_stores (PATTERN (insn), move_xbitmap, set);
+ insn = PREV_INSN (insn);
+ }
+ }
+ }
+
+
tem = emit_insn_after_setloc (seq, trial, INSN_LOCATOR (trial));
delete_insn (trial);
Index: var-mappings-branch/gcc/testsuite/gcc.dg/tree-ssa/vars-2.c
===================================================================
*** /dev/null 1970-01-01 00:00:00.000000000 +0000
--- var-mappings-branch/gcc/testsuite/gcc.dg/tree-ssa/vars-2.c 2007-11-12 17:55:40.000000000 +0100
***************
*** 0 ****
--- 1,21 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -g -fvar-tracking -fdump-tree-final_cleanup-vars -fdump-rtl-vartrack" } */
+
+ /* In this test we want to keep the name "j" associated with
+ the expression "i * 2" passed to the inlined function "bar"
+ even in the presence of RTL splitters. */
+
+ static int bar(int j)
+ {
+ return j;
+ }
+ int l;
+ int foo(int i)
+ {
+ l = bar(i*2);
+ return l;
+ }
+
+ /* { dg-final { scan-tree-dump "i \\\* 2 E{ j }" "final_cleanup" } } */
+ /* { dg-final { scan-rtl-dump "\\\[orig:.* j \\\]" "vartrack" } } */
+ /* { dg-final { cleanup-tree-dump "final_cleanup" } } */