www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1999/10/04/20:42:40

Date: Tue, 5 Oct 1999 00:29:13 +0200 (MET DST)
From: grenie AT math DOT jussieu DOT fr (Loic Grenie)
Message-Id: <199910042229.AAA21543@riemann.math.jussieu.fr>
To: pgcc AT delorie DOT com
Subject: Compare elimination bug.
MIME-Version: 1.0
Reply-To: pgcc AT delorie DOT com

    I've isolated the bug I told you about last time, that is the one that
  caused a small loop to be miscompiled. I recall the problem: the file is

void func(void)
{
    int i, tab[512];

    for (i = 0; i < 511; i++)
	tab[i+1] = tab[i];
}

  is miscompiled with -O4 -mpentium and correctly with -fno-compare-elim. By
  changing the file loop.c according to the following patch, the problem is
  corrected for the given example. I think the patch cover all cases, but I'm
  not a compiler specialist, so it would be better to have a good look at
  it. (there could be some lines of offset since I also corrected a
  misallocation in this file, already submitted to the list)

     Loïc

--- loop.c.orig	Mon Oct  4 22:30:22 1999
+++ loop.c	Tue Oct  5 00:16:17 1999
@@ -10546,7 +10546,7 @@
               obfree(storage);
               return 0;
             }
-          else if (!rtx_equal_p (SET_DEST (PATTERN (insn)), SET_DEST (bl->init_set)))
+          else
 	    {
 	      new_rtx_element = (struct new_rtx *) alloca (sizeof (struct new_rtx));
 	      new_rtx_element->insn = insn;
@@ -10576,6 +10576,19 @@
 		      obfree (storage);
 		      return 0;
 		    }
+	        }
+
+	      if (rtx_equal_p (SET_DEST (PATTERN (insn)), SET_DEST (bl->init_set)))
+	        {
+		  emit_insn_after(gen_rtx (SET,
+					GET_MODE(SET_DEST(PATTERN(insn))),
+					SET_DEST(PATTERN(insn)),
+					gen_rtx(PLUS,
+					    GET_MODE(SET_DEST(PATTERN(insn))),
+					    SET_DEST(PATTERN(insn)),
+							gen_rtx(CONST_INT, 0,
+							      -adjust_val))),
+				insn);
 	        }
 	    }
 	}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019