https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91016

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
ix86_expand_sse_compare_mask generates temporary by itself, so the REG RTX is
just overwritten. There is no issue with reusage of pseudos as they are short
lived, and die in AND RTX anyway. OTOH, non-AVX AND RTX requires matched
registers so I guess that this is a non-issue.

I think the following (untested) patch should fix all mentioned issues for
good:

--cut here--
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index d50b811d863f..8a4955f87d2f 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -16052,14 +16052,13 @@ ix86_expand_rounddf_32 (rtx operand0, rtx operand1)
                               0, OPTAB_DIRECT);

   /* Compensate.  */
-  tmp = gen_reg_rtx (mode);
   /* xa2 = xa2 - (dxa > 0.5 ? 1 : 0) */
   tmp = ix86_expand_sse_compare_mask (UNGT, dxa, half, false);
-  emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
+  emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, tmp, one)));
   xa2 = expand_simple_binop (mode, MINUS, xa2, tmp, NULL_RTX, 0,
OPTAB_DIRECT);
   /* xa2 = xa2 + (dxa <= -0.5 ? 1 : 0) */
   tmp = ix86_expand_sse_compare_mask (UNGE, mhalf, dxa, false);
-  emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
+  emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, tmp, one)));
   xa2 = expand_simple_binop (mode, PLUS, xa2, tmp, NULL_RTX, 0, OPTAB_DIRECT);

   /* res = copysign (xa2, operand1) */
--cut here--

Reply via email to