diff options
author | Vladimir N. Makarov <vmakarov@redhat.com> | 2023-03-31 11:04:44 -0400 |
---|---|---|
committer | Vladimir N. Makarov <vmakarov@redhat.com> | 2023-03-31 11:05:45 -0400 |
commit | e9910e002d610db6e08230583c2976c9a557131b (patch) | |
tree | 8557d7841d62df97bc2697d96bc67a8ccaf5be25 /gcc | |
parent | a35e8042fbc7a3eb9cece1fba4cdd3b6cdfb906f (diff) | |
download | gcc-e9910e002d610db6e08230583c2976c9a557131b.zip gcc-e9910e002d610db6e08230583c2976c9a557131b.tar.gz gcc-e9910e002d610db6e08230583c2976c9a557131b.tar.bz2 |
LRA: Implement commutative operands exchange for combining secondary memory reload and original insn
The patch implements trying commutative operands exchange for
combining secondary memory reload and original insn.
PR rtl-optimization/109052
gcc/ChangeLog:
* lra-constraints.cc: (combine_reload_insn): New function.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr109052-2.c: New.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/lra-constraints.cc | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr109052-2.c | 10 |
2 files changed, 27 insertions, 1 deletions
diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index 405b8b9..ff4e8f0 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -5061,7 +5061,23 @@ combine_reload_insn (rtx_insn *from, rtx_insn *to) curr_insn = to; curr_id = lra_get_insn_recog_data (curr_insn); curr_static_id = curr_id->insn_static_data; - ok_p = !curr_insn_transform (true); + for (bool swapped_p = false;;) + { + ok_p = !curr_insn_transform (true); + if (ok_p || curr_static_id->commutative < 0) + break; + swap_operands (curr_static_id->commutative); + if (lra_dump_file != NULL) + { + fprintf (lra_dump_file, + " Swapping %scombined insn operands:\n", + swapped_p ? "back " : ""); + dump_insn_slim (lra_dump_file, to); + } + if (swapped_p) + break; + swapped_p = true; + } curr_insn = saved_insn; curr_id = lra_get_insn_recog_data (curr_insn); curr_static_id = curr_id->insn_static_data; diff --git a/gcc/testsuite/gcc.target/i386/pr109052-2.c b/gcc/testsuite/gcc.target/i386/pr109052-2.c new file mode 100644 index 0000000..337d1f4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr109052-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mfpmath=both -mavx -fno-math-errno" } */ + +double foo (double a, double b) +{ + double z = __builtin_fmod (a, 3.14); + return z * b; +} + +/* { dg-final { scan-assembler-not "vmulsd\[ \t]\+%xmm\[0-9]\+, %xmm\[0-9]\+, %xmm\[0-9]\+"} } */ |