mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-26 07:40:26 +08:00
re PR tree-optimization/36881 (Creating runtime relocations for code which does not need it)
PR tree-optimization/36881 * tree-switch-conversion.c (check_final_bb): For flag_pic, check that each value doesn't need runtime relocations, for !flag_pic check that each value is just a valid initializer constant. * gcc.dg/tree-ssa/pr36881.c: New test. From-SVN: r141129
This commit is contained in:
parent
e3bc2fa7e6
commit
f6e6e9904c
gcc
@ -1,3 +1,10 @@
|
||||
2008-10-15 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR tree-optimization/36881
|
||||
* tree-switch-conversion.c (check_final_bb): For flag_pic, check
|
||||
that each value doesn't need runtime relocations, for !flag_pic
|
||||
check that each value is just a valid initializer constant.
|
||||
|
||||
2008-10-14 Richard Sandiford <rdsandiford@googlemail.com>
|
||||
|
||||
* config/mips/mips.h (reg_class): Remove HI_AND_GR_REGS,
|
||||
|
@ -1,3 +1,8 @@
|
||||
2008-10-15 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR tree-optimization/36881
|
||||
* gcc.dg/tree-ssa/pr36881.c: New test.
|
||||
|
||||
2008-10-14 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/37819
|
||||
|
23
gcc/testsuite/gcc.dg/tree-ssa/pr36881.c
Normal file
23
gcc/testsuite/gcc.dg/tree-ssa/pr36881.c
Normal file
@ -0,0 +1,23 @@
|
||||
/* PR tree-optimization/36881 */
|
||||
/* { dg-do compile { target fpic } } */
|
||||
/* { dg-options "-O2 -fpic -fdump-tree-switchconv-all" } */
|
||||
|
||||
const char *foo (int i)
|
||||
{
|
||||
const char *p;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
case 6: p = ""; break;
|
||||
case 1:
|
||||
case 7: p = "abc"; break;
|
||||
case 2:
|
||||
case 8: p = "def"; break;
|
||||
default: p = "ghi"; break;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-not "CSWTCH" } } */
|
||||
/* { dg-final { scan-tree-dump "need runtime relocations" "switchconv" } } */
|
||||
/* { dg-final { cleanup-tree-dump "switchconv" } } */
|
@ -296,12 +296,29 @@ check_final_bb (void)
|
||||
{
|
||||
basic_block bb = gimple_phi_arg_edge (phi, i)->src;
|
||||
|
||||
if ((bb == info.switch_bb
|
||||
|| (single_pred_p (bb) && single_pred (bb) == info.switch_bb))
|
||||
&& !is_gimple_ip_invariant (gimple_phi_arg_def (phi, i)))
|
||||
if (bb == info.switch_bb
|
||||
|| (single_pred_p (bb) && single_pred (bb) == info.switch_bb))
|
||||
{
|
||||
info.reason = " Non-invariant value from a case\n";
|
||||
return false; /* Non-invariant argument. */
|
||||
tree reloc, val;
|
||||
|
||||
val = gimple_phi_arg_def (phi, i);
|
||||
if (!is_gimple_ip_invariant (val))
|
||||
{
|
||||
info.reason = " Non-invariant value from a case\n";
|
||||
return false; /* Non-invariant argument. */
|
||||
}
|
||||
reloc = initializer_constant_valid_p (val, TREE_TYPE (val));
|
||||
if ((flag_pic && reloc != null_pointer_node)
|
||||
|| (!flag_pic && reloc == NULL_TREE))
|
||||
{
|
||||
if (reloc)
|
||||
info.reason
|
||||
= " Value from a case would need runtime relocations\n";
|
||||
else
|
||||
info.reason
|
||||
= " Value from a case is not a valid initializer\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user