Hi,

This patch allows uninitialized registers usage in instructions
converted by STV pass.  Bootstrapped and tested on x86_64-pc-linux-gnu{-m32}.
OK for trunk?

Thanks,
Ilya
--
gcc/

2016-03-22  Ilya Enkovich  <enkovich....@gmail.com>

        PR target/70302
        * config/i386/i386.c (scalar_chain::convert_op): Support
        uninitialized register usage case.

gcc/testsuite/

2016-03-22  Ilya Enkovich  <enkovich....@gmail.com>

        PR target/70302
        * gcc.target/i386/pr70302.c: New test.


diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 3d8dbc4..d25c5c4 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3409,6 +3409,20 @@ scalar_chain::convert_op (rtx *op, rtx_insn *insn)
        fprintf (dump_file, "  Preloading operand for insn %d into r%d\n",
                 INSN_UID (insn), REGNO (tmp));
     }
+  else if (REG_P (*op))
+    {
+      /* We may have not converted register usage in case
+        this register has no definition.  Otherwise it
+        should be converted in convert_reg.  */
+      df_ref ref;
+      FOR_EACH_INSN_USE (ref, insn)
+       if (DF_REF_REGNO (ref) == REGNO (*op))
+         {
+           gcc_assert (!DF_REF_CHAIN (ref));
+           break;
+         }
+      *op = gen_rtx_SUBREG (V2DImode, *op, 0);
+    }
   else
     {
       gcc_assert (SUBREG_P (*op));
diff --git a/gcc/testsuite/gcc.target/i386/pr70302.c 
b/gcc/testsuite/gcc.target/i386/pr70302.c
new file mode 100644
index 0000000..9b82a0c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr70302.c
@@ -0,0 +1,22 @@
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-O2 -msse2" } */
+
+long a, c, e;
+int b, d;
+unsigned long long f;
+
+extern void fn2 (const char *, int, int, int);
+
+void
+fn1(long long p1)
+{
+  unsigned long long g;
+  int i;
+  for (; i;)
+    if (e)
+      g = c;
+  if (a)
+    f = p1;
+  if (!f && !g)
+    fn2("", b, d, d);
+}

Reply via email to