https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112406

--- Comment #6 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
First reduction:

typedef struct {
  int red
} MagickPixelPacket;
GetImageChannelMoments_image, GetImageChannelMoments_image_0,
    GetImageChannelMoments___trans_tmp_1, GetImageChannelMoments_M11_0,
    GetImageChannelMoments_pixel_3, GetImageChannelMoments_y,
    GetImageChannelMoments_p;
double GetImageChannelMoments_M00_0, GetImageChannelMoments_M00_1,
    GetImageChannelMoments_M01_1;
MagickPixelPacket GetImageChannelMoments_pixel;
SetMagickPixelPacket(int color, MagickPixelPacket *pixel) {
  pixel->red = color;
}
GetImageChannelMoments() {
  for (; GetImageChannelMoments_y; GetImageChannelMoments_y++) {
    SetMagickPixelPacket(GetImageChannelMoments_p,
                         &GetImageChannelMoments_pixel);
    GetImageChannelMoments_M00_1 += GetImageChannelMoments_pixel.red;
    if (GetImageChannelMoments_image)
      GetImageChannelMoments_M00_1++;
    GetImageChannelMoments_M01_1 +=
        GetImageChannelMoments_y * GetImageChannelMoments_pixel_3;
    if (GetImageChannelMoments_image_0)
      GetImageChannelMoments_M00_0++;
    GetImageChannelMoments_M01_1 +=
        GetImageChannelMoments_y * GetImageChannelMoments_p++;
  }
  GetImageChannelMoments___trans_tmp_1 = atan(GetImageChannelMoments_M11_0);
}

reproduce with:

gcc -march=armv8-a+sve -w -Ofast statistic.i -o statistic.o

bisected to:

01c18f58d37865d5f3bbe93e666183b54ec608c7 is the first bad commit
commit 01c18f58d37865d5f3bbe93e666183b54ec608c7
Author: Robin Dapp <rd...@ventanamicro.com>
Date:   Wed Sep 13 22:19:35 2023 +0200

    ifcvt/vect: Emit COND_OP for conditional scalar reduction.

    As described in PR111401 we currently emit a COND and a PLUS expression
    for conditional reductions.  This makes it difficult to combine both
    into a masked reduction statement later.
    This patch improves that by directly emitting a COND_ADD/COND_OP during
    ifcvt and adjusting some vectorizer code to handle it.

    It also makes neutral_op_for_reduction return -0 if HONOR_SIGNED_ZEROS
    is true.

    gcc/ChangeLog:

            PR middle-end/111401
            * internal-fn.cc (internal_fn_else_index): New function.
            * internal-fn.h (internal_fn_else_index): Define.
            * tree-if-conv.cc (convert_scalar_cond_reduction): Emit COND_OP
            if supported.
            (predicate_scalar_phi): Add whitespace.
            * tree-vect-loop.cc (fold_left_reduction_fn): Add IFN_COND_OP.
            (neutral_op_for_reduction): Return -0 for PLUS.
            (check_reduction_path): Don't count else operand in COND_OP.
            (vect_is_simple_reduction): Ditto.
            (vect_create_epilog_for_reduction): Fix whitespace.
            (vectorize_fold_left_reduction): Add COND_OP handling.
            (vectorizable_reduction): Don't count else operand in COND_OP.
            (vect_transform_reduction): Add COND_OP handling.
            * tree-vectorizer.h (neutral_op_for_reduction): Add default
            parameter.

    gcc/testsuite/ChangeLog:

            * gcc.dg/vect/vect-cond-reduc-in-order-2-signed-zero.c: New test.
            * gcc.target/riscv/rvv/autovec/cond/pr111401.c: New test.
            * gcc.target/riscv/rvv/autovec/reduc/reduc_call-2.c: Adjust.
            * gcc.target/riscv/rvv/autovec/reduc/reduc_call-4.c: Ditto.

--

I'll start on the exchange one now.

Reply via email to