From 756f55e62f73eb32787497eb9e564d4b21a6e637 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Thu, 3 Dec 2020 17:49:42 +0100 Subject: [PATCH] i386: Fix up ix86_md_asm_adjust for TImode [PR98086] MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ix86_md_asm_adjust assumes that dest_mode can be only [QHSD]Imode and nothing else. The patch rewrites zero-extension part to use convert_to_mode to handle TImode and hypothetically even wider modes. 2020-12-03 Uroš Bizjak Jakub Jelinek gcc/ PR target/98086 * config/i386/i386.c (ix86_md_asm_adjustmd): Rewrite zero-extension part to use convert_to_mode. gcc/testsuite/ PR target/98086 * gcc.target/i386/pr98086.c: New test. --- gcc/config/i386/i386.c | 38 ++++++------------------- gcc/testsuite/gcc.target/i386/pr98086.c | 17 +++++++++++ 2 files changed, 25 insertions(+), 30 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr98086.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c5db8c9712e..63216782430 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -21508,40 +21508,18 @@ ix86_md_asm_adjust (vec &outputs, vec &/*inputs*/, continue; } - if (dest_mode == DImode && !TARGET_64BIT) - dest_mode = SImode; - - if (dest_mode != QImode) - { - rtx destqi = gen_reg_rtx (QImode); - emit_insn (gen_rtx_SET (destqi, x)); - - if (TARGET_ZERO_EXTEND_WITH_AND - && optimize_function_for_speed_p (cfun)) - { - x = force_reg (dest_mode, const0_rtx); - - emit_insn (gen_movstrictqi (gen_lowpart (QImode, x), destqi)); - } - else - { - x = gen_rtx_ZERO_EXTEND (dest_mode, destqi); - if (dest_mode == GET_MODE (dest) - && !register_operand (dest, GET_MODE (dest))) - x = force_reg (dest_mode, x); - } - } - - if (dest_mode != GET_MODE (dest)) + if (dest_mode == QImode) + emit_insn (gen_rtx_SET (dest, x)); + else { - rtx tmp = gen_reg_rtx (SImode); + rtx reg = gen_reg_rtx (QImode); + emit_insn (gen_rtx_SET (reg, x)); - emit_insn (gen_rtx_SET (tmp, x)); - emit_insn (gen_zero_extendsidi2 (dest, tmp)); + reg = convert_to_mode (dest_mode, reg, 1); + emit_move_insn (dest, reg); } - else - emit_insn (gen_rtx_SET (dest, x)); } + rtx_insn *seq = get_insns (); end_sequence (); diff --git a/gcc/testsuite/gcc.target/i386/pr98086.c b/gcc/testsuite/gcc.target/i386/pr98086.c new file mode 100644 index 00000000000..254a3b9bef6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr98086.c @@ -0,0 +1,17 @@ +/* PR target/98086 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#ifdef __x86_64__ +typedef __int128 T; +#else +typedef long long T; +#endif + +T x; + +void +foo (void) +{ + __asm ("" : "=@ccc" (x)); +} -- 2.30.2