ipcp_update_vr does not need to specialize pointers
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap |
fail
|
Patch failed to apply
|
Commit Message
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...
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.
---
gcc/ipa-prop.cc | 63 ++------------------------
gcc/testsuite/gcc.dg/ipa/propalign-1.c | 2 +-
gcc/testsuite/gcc.dg/ipa/propalign-2.c | 2 +-
gcc/testsuite/gcc.dg/ipa/propalign-4.c | 2 +-
gcc/testsuite/gcc.dg/ipa/propalign-5.c | 2 +-
5 files changed, 7 insertions(+), 64 deletions(-)
Comments
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.
@@ -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);
@@ -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" } } */
@@ -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" } } */
@@ -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" } } */
@@ -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" } } */