From: Jakub Jelinek Date: Fri, 4 Oct 2024 10:36:52 +0000 (+0200) Subject: i386: Fix up *minmax3_2 splitter [PR116925] X-Git-Tag: basepoints/gcc-16~5491 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67b750c20e1f9428ef89a6fed0103e912bea8679;p=thirdparty%2Fgcc.git i386: Fix up *minmax3_2 splitter [PR116925] While *minmax3_1 correctly uses if (MEM_P (operands[1])) operands[1] = force_reg (mode, operands[1]); to ensure operands[1] is not a MEM, *minmax3_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 PR target/116925 * config/i386/sse.md (*minmax3_2): Assign force_reg result back to operands[2] instead of throwing it away. * g++.target/i386/avx-pr116925.C: New test. --- diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 183c1953f91..d6e2135423d 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, operands[2]); + operands[2] = force_reg (mode, operands[2]); rtvec v = gen_rtvec (2, operands[2], operands[1]); rtx tmp = gen_rtx_UNSPEC (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 00000000000..b2d6fc1856b --- /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; +}