diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-07-23 21:44:39 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-08-01 00:06:14 +0000 |
commit | cc2003cd87532f319c94028f17d20a327df5ccfa (patch) | |
tree | 6d20131ed1cef0c45a9a4f839ee8517a05a54ab6 /gcc/tree-cfg.cc | |
parent | a349ba16f18b66b70c7a1bdb1ab5c5b6247676da (diff) | |
download | gcc-cc2003cd87532f319c94028f17d20a327df5ccfa.zip gcc-cc2003cd87532f319c94028f17d20a327df5ccfa.tar.gz gcc-cc2003cd87532f319c94028f17d20a327df5ccfa.tar.bz2 |
Fix PR 93044: extra cast is not removed
In this case we are not removing convert to a bigger size
back to the same size (or smaller) if signedness does not
match.
For an example:
```
signed char _1;
...
_1 = *a_4(D);
b_5 = (short unsigned int) _1;
_2 = (unsigned char) b_5;
```
The inner cast is not needed and can be removed but was not.
The match pattern for removing the extra cast is overly
complex so decided to add a new case for rather than trying
to modify the current if statement here.
Committed as approved. Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
PR tree-optimization/93044
* match.pd (nested int casts): A truncation (to the same size or smaller)
can always remove the inner cast.
gcc/testsuite/ChangeLog:
PR tree-optimization/93044
* gcc.dg/tree-ssa/cast-1.c: New test.
* gcc.dg/tree-ssa/cast-2.c: New test.
Diffstat (limited to 'gcc/tree-cfg.cc')
0 files changed, 0 insertions, 0 deletions