--- /dev/null
+/* { dg-require-effective-target vect_float } */
+
+#include <stdlib.h>
+#include "tree-vect.h"
+
+void interp_pitch(float *exc, float *interp, int pitch, int len)
+{
+ int i,k;
+ int maxj;
+
+ maxj=3;
+ for (i=0;i<len;i++)
+ {
+ float tmp = 0;
+ for (k=0;k<7;k++)
+ {
+ tmp += exc[i-pitch+k+maxj-6];
+ }
+ interp[i] = tmp;
+ }
+}
+
+int main()
+{
+ float *exc = calloc(126,sizeof(float));
+ float *interp = calloc(80,sizeof(float));
+ int pitch = -35;
+
+ check_vect ();
+
+ interp_pitch(exc, interp, pitch, 80);
+ free(exc);
+ free(interp);
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Extract INVARIANT and CONSTANT parts from OFFSET.
*/
-static void
+static bool
analyze_offset (tree offset, tree *invariant, tree *constant)
{
tree op0, op1, constant_0, constant_1, invariant_0, invariant_1;
*constant = offset;
else
*invariant = offset;
- return;
+ return true;
}
op0 = TREE_OPERAND (offset, 0);
op1 = TREE_OPERAND (offset, 1);
/* Recursive call with the operands. */
- analyze_offset (op0, &invariant_0, &constant_0);
- analyze_offset (op1, &invariant_1, &constant_1);
+ if (!analyze_offset (op0, &invariant_0, &constant_0)
+ || !analyze_offset (op1, &invariant_1, &constant_1))
+ return false;
- /* Combine the results. */
+ /* Combine the results. Add negation to the subtrahend in case of
+ subtraction. */
+ if (constant_0 && constant_1)
+ return false;
*constant = constant_0 ? constant_0 : constant_1;
+ if (code == MINUS_EXPR && constant_1)
+ *constant = fold_build1 (NEGATE_EXPR, TREE_TYPE (*constant), *constant);
+
if (invariant_0 && invariant_1)
*invariant =
fold_build2 (code, TREE_TYPE (invariant_0), invariant_0, invariant_1);
else
- *invariant = invariant_0 ? invariant_0 : invariant_1;
+ {
+ *invariant = invariant_0 ? invariant_0 : invariant_1;
+ if (code == MINUS_EXPR && invariant_1)
+ *invariant =
+ fold_build1 (NEGATE_EXPR, TREE_TYPE (*invariant), *invariant);
+ }
+ return true;
}
/* Free the memory used by the data reference DR. */
STRIP_NOPS (offset);
if (offset != orig_offset)
type = TREE_TYPE (orig_offset);
- analyze_offset (offset, &invariant, &constant);
+ if (!analyze_offset (offset, &invariant, &constant))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "\ncreate_data_ref: failed to analyze dr's");
+ fprintf (dump_file, " offset for ");
+ print_generic_expr (dump_file, memref, TDF_SLIM);
+ fprintf (dump_file, "\n");
+ }
+ return NULL;
+ }
if (type && invariant)
invariant = fold_convert (type, invariant);