[1/2] middle-end/116083 - vectorizer slowness
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
Commit Message
Turns out SLP discovery can end up doing a lot of vector type
builds from scalar types. Those are all ultimatively cached but
end up built and layouted first. The latter is particularly
expensive because it does tree node arithmetic to compute TYPE_SIZE
and TYPE_SIZE_UNIT. The following replaces this with the appropriate
poly-int arithmetic which speeds up the testcase by 50%.
Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
Even after 2/2 this speeds up compilation by 5%.
PR middle-end/116083
* stor-layout.cc (layout_type): Compute TYPE_SIZE and
TYPE_SIZE_UNIT for vector types from the component mode
sizes.
---
gcc/stor-layout.cc | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
Comments
On 12/3/24 10:07 AM, Richard Biener wrote:
> Turns out SLP discovery can end up doing a lot of vector type
> builds from scalar types. Those are all ultimatively cached but
> end up built and layouted first. The latter is particularly
> expensive because it does tree node arithmetic to compute TYPE_SIZE
> and TYPE_SIZE_UNIT. The following replaces this with the appropriate
> poly-int arithmetic which speeds up the testcase by 50%.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
>
> Even after 2/2 this speeds up compilation by 5%.
>
> PR middle-end/116083
> * stor-layout.cc (layout_type): Compute TYPE_SIZE and
> TYPE_SIZE_UNIT for vector types from the component mode
> sizes.
OK
jeff
@@ -2591,16 +2591,21 @@ layout_type (tree type)
/* Several boolean vector elements may fit in a single unit. */
if (VECTOR_BOOLEAN_TYPE_P (type)
&& type->type_common.mode != BLKmode)
- TYPE_SIZE_UNIT (type)
- = size_int (GET_MODE_SIZE (type->type_common.mode));
+ {
+ TYPE_SIZE_UNIT (type)
+ = size_int (GET_MODE_SIZE (type->type_common.mode));
+ TYPE_SIZE (type)
+ = bitsize_int (GET_MODE_BITSIZE (type->type_common.mode));
+ }
else
- TYPE_SIZE_UNIT (type) = int_const_binop (MULT_EXPR,
- TYPE_SIZE_UNIT (innertype),
- size_int (nunits));
- TYPE_SIZE (type) = int_const_binop
- (MULT_EXPR,
- bits_from_bytes (TYPE_SIZE_UNIT (type)),
- bitsize_int (BITS_PER_UNIT));
+ {
+ TYPE_SIZE_UNIT (type)
+ = size_int (GET_MODE_SIZE (SCALAR_TYPE_MODE (innertype))
+ * nunits);
+ TYPE_SIZE (type)
+ = bitsize_int (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (innertype))
+ * nunits);
+ }
/* For vector types, we do not default to the mode's alignment.
Instead, query a target hook, defaulting to natural alignment.