| Message ID | 438b9ccc-c789-4e9f-a18b-05c0b4baf4a0@redhat.com |
|---|---|
| State | New |
| Headers | show |
| Series | ipcp_update_vr does not need to specialize pointers | expand |
Hi, On Tue, Nov 03 2026, Andrew MacLeod wrote: > This patch removes the specialization for pointers when they did not have bitmasks. > > I think it is correct... but there is a alight difference... the old > pointer code was guarded by pt_for_fn (node->decl, flag_ipa_bit_cp), > but the integer code was not... The set_range_info (ddef, tmp); would > always set the bitmask regardess of hte flag, and with pointers now > having bitmaks, they do the same thing... > In this regard the change is fine, this is transformation code and so if the flag is false, the vector of value ranges to set should be empty. I trust you that the special pointer code now indeed is not necessary and so the change is OK. Martin > I presume the desired behaviour wouold be to have pointers do the same thing.. which perserves the bitmask and therefore the alignment.. always, regardless of that flag. Is that the correct call? get_ptr_alignment simply picks things up from the bitmask anyway now. > > Without all the special pointer code, the output in a couple of testcases need to be adjusted. > > Bootstraps on x86_64-pc-linux-gnu with no regressions. OK for trunk? > > Andrew > > > > With pointers having global ranges now, the bitmask maintains all > alignment info so no need to do special alignment copying. > > gcc/ > * ipa-prop.cc (ipcp_update_vr): Pointers have global bitmasks > now which contain the alignment info. > > gcc/testsuite/ > * gcc.dg/ipa/propalign-1.c: Adjust for new output. > * gcc.dg/ipa/propalign-2.c: Adjust for new output. > * gcc.dg/ipa/propalign-4.c: Adjust for new output. > * gcc.dg/ipa/propalign-5.c: Adjust for new output.
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 473239db36d..eb220b92eab 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -6669,68 +6669,11 @@ ipcp_update_vr (struct cgraph_node *node, ipcp_transformation *ts) } set_range_info (ddef, tmp); - if (POINTER_TYPE_P (TREE_TYPE (parm)) - && opt_for_fn (node->decl, flag_ipa_bit_cp)) + if (dump_file && (INTEGRAL_TYPE_P (TREE_TYPE (parm)) + || POINTER_TYPE_P (TREE_TYPE (parm)))) { irange_bitmask bm = tmp.get_bitmask (); - unsigned tem = bm.mask ().to_uhwi (); - unsigned HOST_WIDE_INT bitpos = bm.value ().to_uhwi (); - unsigned align = tem & -tem; - unsigned misalign = bitpos & (align - 1); - - if (align > 1) - { - if (dump_file) - { - fprintf (dump_file, - "Adjusting mask for param %u to ", i); - print_hex (bm.mask (), dump_file); - fprintf (dump_file, "\n"); - } - - if (dump_file) - fprintf (dump_file, - "Adjusting align: %u, misalign: %u\n", - align, misalign); - - unsigned old_align, old_misalign; - bool old_known - = get_ptr_info_alignment (ddef, &old_align, - &old_misalign); - - if (old_known && old_align > align) - { - if (dump_file) - { - fprintf (dump_file, - "But alignment was already %u.\n", - old_align); - if ((old_misalign & (align - 1)) != misalign) - fprintf (dump_file, - "old_misalign (%u) and misalign " - "(%u) mismatch\n", - old_misalign, misalign); - } - continue; - } - - if (dump_file - && old_known - && ((misalign & (old_align - 1)) != old_misalign)) - fprintf (dump_file, - "old_misalign (%u) and misalign (%u) " - "mismatch\n", - old_misalign, misalign); - - set_ptr_info_alignment (ddef, align, misalign); - } - } - else if (dump_file && INTEGRAL_TYPE_P (TREE_TYPE (parm))) - { - irange &r = as_a<irange> (tmp); - irange_bitmask bm = r.get_bitmask (); - unsigned prec = TYPE_PRECISION (TREE_TYPE (parm)); - if (wi::ne_p (bm.mask (), wi::shwi (-1, prec))) + if (!bm.unknown_p ()) { fprintf (dump_file, "Adjusting mask for param %u to ", i); diff --git a/gcc/testsuite/gcc.dg/ipa/propalign-1.c b/gcc/testsuite/gcc.dg/ipa/propalign-1.c index 1491de8d550..a8d0021cb01 100644 --- a/gcc/testsuite/gcc.dg/ipa/propalign-1.c +++ b/gcc/testsuite/gcc.dg/ipa/propalign-1.c @@ -27,5 +27,5 @@ bar (void) } -/* { dg-final { scan-ipa-dump "Adjusting align" "cp" } } */ +/* { dg-final { scan-ipa-dump "Adjusting mask for param" "cp" } } */ /* { dg-final { scan-tree-dump-not "fail_the_test" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/propalign-2.c b/gcc/testsuite/gcc.dg/ipa/propalign-2.c index 51799c7fbd1..5122938e076 100644 --- a/gcc/testsuite/gcc.dg/ipa/propalign-2.c +++ b/gcc/testsuite/gcc.dg/ipa/propalign-2.c @@ -53,5 +53,5 @@ bar2 (void) through (c.buf); } -/* { dg-final { scan-ipa-dump "Adjusting align" "cp" } } */ +/* { dg-final { scan-ipa-dump "Adjusting mask for param" "cp" } } */ /* { dg-final { scan-tree-dump-not "fail_the_test" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/propalign-4.c b/gcc/testsuite/gcc.dg/ipa/propalign-4.c index bd32bf09241..692adb00eda 100644 --- a/gcc/testsuite/gcc.dg/ipa/propalign-4.c +++ b/gcc/testsuite/gcc.dg/ipa/propalign-4.c @@ -20,4 +20,4 @@ main() test (&aa[3]); return 0; } -/* { dg-final { scan-ipa-dump "align: 8, misalign: 4" "cp" } } */ +/* { dg-final { scan-ipa-dump "Setting value range of param 0 .*MASK 0xf+8 VALUE 0x4" "cp" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/propalign-5.c b/gcc/testsuite/gcc.dg/ipa/propalign-5.c index 68e57da30d7..2e0f74b9c1a 100644 --- a/gcc/testsuite/gcc.dg/ipa/propalign-5.c +++ b/gcc/testsuite/gcc.dg/ipa/propalign-5.c @@ -20,4 +20,4 @@ main() test (&bb); return 0; } -/* { dg-final { scan-ipa-dump "align: 2" "cp" } } */ +/* { dg-final { scan-ipa-dump "Setting value range of param 0 .*MASK 0xf+e VALUE 0x0" "cp" } } */