From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id D9E98385DC06; Tue, 29 Mar 2022 05:53:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9E98385DC06 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9720] i386: Use a new temp slot kind for splitter to floatdi2_i387_with_xmm [PR104674] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 1305c28bc0665504643ff364595b7d6bb222745d X-Git-Newrev: acb9ea44fcceea0a54a89c7f94af4338c10759ef Message-Id: <20220329055326.D9E98385DC06@sourceware.org> Date: Tue, 29 Mar 2022 05:53:26 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2022 05:53:27 -0000 https://gcc.gnu.org/g:acb9ea44fcceea0a54a89c7f94af4338c10759ef commit r11-9720-gacb9ea44fcceea0a54a89c7f94af4338c10759ef Author: Jakub Jelinek Date: Fri Feb 25 12:06:52 2022 +0100 i386: Use a new temp slot kind for splitter to floatdi2_i387_with_xmm [PR104674] As mentioned in the PR, the following testcase is miscompiled for similar reasons as the already fixed PR78791 - we use SLOT_TEMP slots in various places during expansion and during expansion we can guarantee that the lifetime of those temporary slot doesn't overlap. But the following splitter uses SLOT_TEMP too and in between expansion and split1 there is a possibility that something extends the lifetime of SLOT_TEMP created slots across an instruction that will be split by this splitter. The following patch fixes it by using a new temp slot kind to make sure it doesn't reuse a SLOT_TEMP that could be live across the instruction. 2022-02-25 Jakub Jelinek PR target/104674 * config/i386/i386.h (enum ix86_stack_slot): Add SLOT_FLOATxFDI_387. * config/i386/i386.md (splitter to floatdi2_i387_with_xmm): Use SLOT_FLOATxFDI_387 rather than SLOT_TEMP. * gcc.target/i386/pr104674.c: New test. (cherry picked from commit eabf7bbe601f2c0d87bd0a1012d7a602df2037da) Diff: --- gcc/config/i386/i386.h | 1 + gcc/config/i386/i386.md | 5 ++--- gcc/testsuite/gcc.target/i386/pr104674.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 431f0bcb4f2..ac0e5da623c 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2652,6 +2652,7 @@ enum ix86_stack_slot SLOT_CW_FLOOR, SLOT_CW_CEIL, SLOT_STV_TEMP, + SLOT_FLOATxFDI_387, MAX_386_STACK_LOCALS }; diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index efe0b4ac3a8..238ce09672e 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -5001,9 +5001,8 @@ && can_create_pseudo_p ()" [(const_int 0)] { - emit_insn (gen_floatdi2_i387_with_xmm - (operands[0], operands[1], - assign_386_stack_local (DImode, SLOT_TEMP))); + rtx s = assign_386_stack_local (DImode, SLOT_FLOATxFDI_387); + emit_insn (gen_floatdi2_i387_with_xmm (operands[0], operands[1], s)); DONE; }) diff --git a/gcc/testsuite/gcc.target/i386/pr104674.c b/gcc/testsuite/gcc.target/i386/pr104674.c new file mode 100644 index 00000000000..c8f3e9b02d6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr104674.c @@ -0,0 +1,31 @@ +/* PR target/104674 */ +/* { dg-do run { target sse2_runtime } } */ +/* { dg-options "-O2 -msse2 -mfpmath=sse" } */ + +__attribute__((noipa)) double +bar (double x, double y) +{ + return x + y; +} + +__attribute__((noipa)) double +foo (long long x) +{ + long long a = x / 10000000; + int b = x % 10000000; + double s = (double) a; + double n = (double) b / 1e7; + double t = s + n; + if (t == s + 1.0) + t = bar (t, s); + return t; +} + +int +main () +{ + long long n = 888888; + n = n * 10000000; + if (foo (n) != 888888.0) + __builtin_abort (); +}