From 0ca5fbc0cacad02f25e24d7736f20571554199ed Mon Sep 17 00:00:00 2001
From: Roger Sayle <roger@eyesopen.com>
Date: Sun, 2 Jan 2005 00:15:01 +0000
Subject: [PATCH] re PR rtl-optimization/12092 (ICE: Floating point exception)

	PR rtl-optimization/12092
	* loop.c (emit_prefetch_instructions): Do nothing if PREFETCH_BLOCK
	is zero.

	* gcc.dg/pr12092-1.c: New test case.

Co-Authored-By: Andrew Pinski <pinskia@physics.uc.edu>
Co-Authored-By: James E Wilson <wilson@specifixinc.com>

From-SVN: r92794
---
 gcc/ChangeLog                    |  8 ++++++++
 gcc/loop.c                       |  7 ++++---
 gcc/testsuite/ChangeLog          |  6 ++++++
 gcc/testsuite/gcc.dg/pr12092-1.c | 12 ++++++++++++
 4 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr12092-1.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 503f15341341..5f5d96e559f3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2005-01-01  Roger Sayle  <roger@eyesopen.com>
+	    Andrew Pinski  <pinskia@physics.uc.edu>
+	    James E. Wilson  <wilson@specifixinc.com>
+
+	PR rtl-optimization/12092
+	* loop.c (emit_prefetch_instructions): Do nothing if PREFETCH_BLOCK
+	is zero.
+
 2005-01-01  Roger Sayle  <roger@eyesopen.com>
 	    Olivier Hainque  <hainque@act-europe.fr>
 
diff --git a/gcc/loop.c b/gcc/loop.c
index faf6cb23b825..7a446eadc12d 100644
--- a/gcc/loop.c
+++ b/gcc/loop.c
@@ -1,6 +1,7 @@
 /* Perform various loop optimizations, including strength reduction.
-   Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -4116,7 +4117,7 @@ emit_prefetch_instructions (struct loop *loop)
   struct prefetch_info info[MAX_PREFETCHES];
   struct loop_ivs *ivs = LOOP_IVS (loop);
 
-  if (!HAVE_prefetch)
+  if (!HAVE_prefetch || PREFETCH_BLOCK == 0)
     return;
 
   /* Consider only loops w/o calls.  When a call is done, the loop is probably
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 97400f7d5bc7..7d2bcc0f0b0f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-01  Roger Sayle  <roger@eyesopen.com>
+	    Andrew Pinski  <pinskia@physics.uc.edu>
+
+	PR rtl-optimization/12092
+	* gcc.dg/pr12092-1.c: New test case.
+
 2005-01-01  Geoffrey Keating  <geoffk@geoffk.org>
 
 	* g++.old-deja/g++.abi/cxa_vec.C: Add -flat_namespace on Darwin
diff --git a/gcc/testsuite/gcc.dg/pr12092-1.c b/gcc/testsuite/gcc.dg/pr12092-1.c
new file mode 100644
index 000000000000..3b13c56452ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr12092-1.c
@@ -0,0 +1,12 @@
+/* PR rtl-optimization/12092  */
+/* Test case reduced by Andrew Pinski <pinskia@physics.uc.edu> */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -mtune=i486 -march=pentium4 -fprefetch-loop-arrays" } */
+
+void DecodeAC(int index,int *matrix)
+{
+  int *mptr;
+
+  for(mptr=matrix+index;mptr<matrix+64;mptr++) {*mptr = 0;}
+}
+
-- 
GitLab