===================================================================
@@ -232,6 +232,11 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_16 (gfc_array_i16 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_4 (gfc_array_i4 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_8 (gfc_array_i8 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_r16 (gfc_array_r16 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_r4 (gfc_array_r4 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -232,6 +232,11 @@ reshape_r8 (gfc_array_r8 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -66,6 +66,10 @@ reshape_internal (parray *ret, parray *source, sha
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT (rdim > 0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -158,6 +162,10 @@ reshape_internal (parray *ret, parray *source, sha
source_extent = 1;
sdim = GFC_DESCRIPTOR_RANK (source);
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
for (n = 0; n < sdim; n++)
{
index_type se;
@@ -219,6 +227,10 @@ reshape_internal (parray *ret, parray *source, sha
}
sdim = GFC_DESCRIPTOR_RANK (source);
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
===================================================================
@@ -111,7 +111,12 @@ typedef off_t gfc_offset;
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
+/* This macro can be used to annotate conditions which we know to
+ be true, so that the compiler can optimize based on the condition. */
+#define GFC_ASSERT(EXPR) \
+ ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
+
/* Make sure we have ptrdiff_t. */
#ifndef HAVE_PTRDIFF_T
typedef intptr_t ptrdiff_t;
===================================================================
@@ -236,6 +236,11 @@ reshape_'rtype_ccode` ('rtype` * const restrict re
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)