diff options
author | Feng Xue <fxue@os.amperecomputing.com> | 2024-08-05 15:23:56 +0800 |
---|---|---|
committer | Feng Xue <fxue@os.amperecomputing.com> | 2024-08-06 11:34:37 +0800 |
commit | 3c089ee5d5a86cab0b27c69b96c4354c496520ac (patch) | |
tree | 69671f96b0c7a030fce9c99e9c06858779d1deb5 /gcc/tree-vect-patterns.cc | |
parent | 0355c943b9e954e8f59068971d934f1b91ecb729 (diff) | |
download | gcc-3c089ee5d5a86cab0b27c69b96c4354c496520ac.zip gcc-3c089ee5d5a86cab0b27c69b96c4354c496520ac.tar.gz gcc-3c089ee5d5a86cab0b27c69b96c4354c496520ac.tar.bz2 |
vect: Allow unsigned-to-signed promotion in vect_look_through_possible_promotion [PR115707]
The function fails to figure out root definition if casts involves more than
two promotions with sign change as:
long a = (long)b; // promotion cast
-> int b = (int)c; // promotion cast, sign change
-> unsigned short c = ...;
For this case, the function thinks the 2nd cast has different sign as the 1st,
so stop looking through, while "unsigned short -> integer" is a nature sign
extension.
2024-08-05 Feng Xue <fxue@os.amperecomputing.com>
gcc/
PR tree-optimization/115707
* tree-vect-patterns.cc (vect_look_through_possible_promotion): Allow
unsigned-to-signed promotion.
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
-rw-r--r-- | gcc/tree-vect-patterns.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 4674a16..b2c83cf 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -434,7 +434,9 @@ vect_look_through_possible_promotion (vec_info *vinfo, tree op, sign of the previous promotion. */ if (!res || TYPE_PRECISION (unprom->type) == orig_precision - || TYPE_SIGN (unprom->type) == TYPE_SIGN (op_type)) + || TYPE_SIGN (unprom->type) == TYPE_SIGN (op_type) + || (TYPE_UNSIGNED (op_type) + && TYPE_PRECISION (op_type) < TYPE_PRECISION (unprom->type))) { unprom->set_op (op, dt, caster); min_precision = TYPE_PRECISION (op_type); |