https://gcc.gnu.org/g:67b750c20e1f9428ef89a6fed0103e912bea8679
commit r15-4062-g67b750c20e1f9428ef89a6fed0103e912bea8679 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Oct 4 12:36:52 2024 +0200 i386: Fix up *minmax<mode>3_2 splitter [PR116925] While *minmax<mode>3_1 correctly uses if (MEM_P (operands[1])) operands[1] = force_reg (<MODE>mode, operands[1]); to ensure operands[1] is not a MEM, *minmax<mode>3_2 does it wrongly by calling force_reg but ignoring its return value. The following borderingly obvious patch fixes that. Didn't find similar other errors in the backend with force_reg calls. 2024-10-04 Jakub Jelinek <ja...@redhat.com> PR target/116925 * config/i386/sse.md (*minmax<mode>3_2): Assign force_reg result back to operands[2] instead of throwing it away. * g++.target/i386/avx-pr116925.C: New test. Diff: --- gcc/config/i386/sse.md | 2 +- gcc/testsuite/g++.target/i386/avx-pr116925.C | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 183c1953f913..d6e2135423d0 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -3269,7 +3269,7 @@ u = UNSPEC_IEEE_MAX; if (MEM_P (operands[2])) - force_reg (<MODE>mode, operands[2]); + operands[2] = force_reg (<MODE>mode, operands[2]); rtvec v = gen_rtvec (2, operands[2], operands[1]); rtx tmp = gen_rtx_UNSPEC (<MODE>mode, v, u); emit_move_insn (operands[0], tmp); diff --git a/gcc/testsuite/g++.target/i386/avx-pr116925.C b/gcc/testsuite/g++.target/i386/avx-pr116925.C new file mode 100644 index 000000000000..b2d6fc1856bf --- /dev/null +++ b/gcc/testsuite/g++.target/i386/avx-pr116925.C @@ -0,0 +1,12 @@ +// PR target/116925 +// { dg-do compile } +// { dg-options "-O2 -mavx -ffloat-store" } + +typedef float V __attribute__((vector_size (16))); +V a, b, c; + +void +foo () +{ + c = a > b ? a : b; +}