* [patch] Avoid division by zero in data-refs dependence analysis
@ 2007-03-22 15:04 Ira Rosen
2007-03-22 17:05 ` Sebastian Pop
0 siblings, 1 reply; 3+ messages in thread
From: Ira Rosen @ 2007-03-22 15:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Revital1 Eres
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
An attempt to divide by zero was made (causing ICE on the attached test
case) for evolution functions with zero step.
Thanks to Revital for the test case.
Bootstrapped and tested on ppc-linux.
O.K. for mainline?
Thanks,
Ira
ChangeLog entry:
* tree-data-ref.c (chrec_steps_divide_constant_p): Avoid division
by 0.
(See attached file: patch.txt)
:ADDPATCH SSA:
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2538 bytes --]
Index: testsuite/gcc.dg/vect/vect-117.c
===================================================================
*** testsuite/gcc.dg/vect/vect-117.c (revision 0)
--- testsuite/gcc.dg/vect/vect-117.c (revision 0)
***************
*** 0 ****
--- 1,40 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target vect_int } */
+
+ #include <stdarg.h>
+ #include "tree-vect.h"
+
+ #define N 16
+
+ struct
+ {
+ unsigned int x;
+ unsigned int y;
+ } pS [100];
+
+ void
+ main1 ()
+ {
+ int i, j;
+ unsigned int ub[N] =
+ { 1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45 };
+ unsigned int uc[N] =
+ { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+ unsigned int udiffx, udiffy;
+
+ for (i = 0; i < N; i++)
+ {
+ pS[i].x = 0;
+ pS[i].y = 0;
+ for (j = 0; j < N; j++)
+ {
+ udiffx = (ub[j] - uc[j]);
+ udiffy = (ub[j] - uc[j]);
+ pS[i].x = udiffx;
+ pS[i].y = udiffy;
+ }
+ }
+ }
+
+ /* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: testsuite/ChangeLog
===================================================================
*** testsuite/ChangeLog (revision 123126)
--- testsuite/ChangeLog (working copy)
***************
*** 1,3 ****
--- 1,7 ----
+ 2007-03-21 Ira Rosen <irar@il.ibm.com>
+
+ * gcc.dg/vect/vect-117.c: New test.
+
2007-03-21 Richard Sandiford <richard@codesourcery.com>
* lib/target-supports.exp (check_effective_target_nonpic): New
Index: tree-data-ref.c
===================================================================
*** tree-data-ref.c (revision 123126)
--- tree-data-ref.c (working copy)
*************** chrec_steps_divide_constant_p (tree chre
*** 3467,3473 ****
case POLYNOMIAL_CHREC:
if (evolution_function_is_constant_p (CHREC_RIGHT (chrec)))
{
! if (tree_fold_divides_p (CHREC_RIGHT (chrec), cst))
/* Keep RES to true, and iterate on other dimensions. */
return chrec_steps_divide_constant_p (CHREC_LEFT (chrec), cst, res);
--- 3467,3474 ----
case POLYNOMIAL_CHREC:
if (evolution_function_is_constant_p (CHREC_RIGHT (chrec)))
{
! if (!integer_zerop (CHREC_RIGHT (chrec))
! && tree_fold_divides_p (CHREC_RIGHT (chrec), cst))
/* Keep RES to true, and iterate on other dimensions. */
return chrec_steps_divide_constant_p (CHREC_LEFT (chrec), cst, res);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Avoid division by zero in data-refs dependence analysis
2007-03-22 15:04 [patch] Avoid division by zero in data-refs dependence analysis Ira Rosen
@ 2007-03-22 17:05 ` Sebastian Pop
2007-03-25 11:53 ` Ira Rosen
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Pop @ 2007-03-22 17:05 UTC (permalink / raw)
To: Ira Rosen; +Cc: gcc-patches, Revital1 Eres
Hello,
On 3/22/07, Ira Rosen <IRAR@il.ibm.com> wrote:
>
> An attempt to divide by zero was made (causing ICE on the attached test
> case) for evolution functions with zero step.
>
I think that this is a problem in tree-scalar-evolution.c as I fail to
see what subscript is having an evolution of 0 in that testcase.
Anyway, I just think that we should never have a chrec with a
step set to zero. So probably it is good to have a check for that
gcc_assert (!integer_zerop (CHREC_RIGHT (chrec)))
in one of the functions building chains of recurrences.
Let me see how I can fix the problem. Can you also send the testcase
as a bug report.
Thank you,
Sebastian
:REVIEWMAIL:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Avoid division by zero in data-refs dependence analysis
2007-03-22 17:05 ` Sebastian Pop
@ 2007-03-25 11:53 ` Ira Rosen
0 siblings, 0 replies; 3+ messages in thread
From: Ira Rosen @ 2007-03-25 11:53 UTC (permalink / raw)
To: Sebastian Pop; +Cc: gcc-patches, Revital1 Eres, sebpop
sebpop@gmail.com wrote on 22/03/2007 17:58:27:
> Hello,
>
> On 3/22/07, Ira Rosen <IRAR@il.ibm.com> wrote:
> >
> > An attempt to divide by zero was made (causing ICE on the attached test
> > case) for evolution functions with zero step.
> >
>
> I think that this is a problem in tree-scalar-evolution.c as I fail to
> see what subscript is having an evolution of 0 in that testcase.
>
> Anyway, I just think that we should never have a chrec with a
> step set to zero. So probably it is good to have a check for that
> gcc_assert (!integer_zerop (CHREC_RIGHT (chrec)))
> in one of the functions building chains of recurrences.
>
> Let me see how I can fix the problem. Can you also send the testcase
> as a bug report.
I opened a PR (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31343).
Thanks,
Ira
>
> Thank you,
> Sebastian
>
> :REVIEWMAIL:
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-25 11:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 15:04 [patch] Avoid division by zero in data-refs dependence analysis Ira Rosen
2007-03-22 17:05 ` Sebastian Pop
2007-03-25 11:53 ` Ira Rosen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).