diff options
author | Andrew Pinski <quic_apinski@quicinc.com> | 2024-08-21 17:41:38 -0700 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2024-08-22 13:51:32 +0200 |
commit | b07f8a301158e53717b8688cc8ea430b6f02574c (patch) | |
tree | 03d0795f8337943ff23722433374b1f0638e929b /gcc/coverage.cc | |
parent | 4e905bd353fc9f37cd35a7e520cb17f993cbd748 (diff) | |
download | gcc-b07f8a301158e53717b8688cc8ea430b6f02574c.zip gcc-b07f8a301158e53717b8688cc8ea430b6f02574c.tar.gz gcc-b07f8a301158e53717b8688cc8ea430b6f02574c.tar.bz2 |
fold: Fix `a * 1j` if a has side effects [PR116454]
The problem here was a missing save_expr around arg0 since
it is used twice, once in REALPART_EXPR and once in IMAGPART_EXPR.
Thia adds the save_expr and reformats the code slightly so it is a
little easier to understand. It excludes the case when arg0 is
a COMPLEX_EXPR since in that case we'll end up with the distinct
real and imaginary parts. This is important to retain early
optimization in some testcases.
Bootstapped and tested on x86_64-linux-gnu with no regressions.
PR middle-end/116454
gcc/ChangeLog:
* fold-const.cc (fold_binary_loc): Fix `a * +-1i`
by wrapping arg0 with save_expr when it is not COMPLEX_EXPR.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr116454-1.c: New test.
* gcc.dg/torture/pr116454-2.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Co-Authored-By: Richard Biener <rguenther@suse.de>
Diffstat (limited to 'gcc/coverage.cc')
0 files changed, 0 insertions, 0 deletions