This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Generate fused widening multiply-and-accumulate operations only when the widening multiply has single use


This patch changes the widening_mul pass to fuse the widening multiply with accumulate only when the multiply has single use. The widening_mul pass currently does the conversion regardless of the number of the uses, which can cause poor code-gen in cases like the following:

typedef int ArrT [10][10];

foo (ArrT Arr, int Idx)
  Arr[Idx][Idx] = 1;
  Arr[Idx + 10][Idx] = 2;

On AArch64, after widening_mul, the IR is like

  _2 = (long unsigned int) Idx_1(D);
  _3 = Idx_1(D) w* 40;                           <----
  _5 = Arr_4(D) + _3;
  *_5[Idx_1(D)] = 1;
  _8 = WIDEN_MULT_PLUS_EXPR <Idx_1(D), 40, 400>; <----
  _9 = Arr_4(D) + _8;
  *_9[Idx_1(D)] = 2;

Where the arrows point, there are redundant widening multiplies.

Bootstrap successfully on x86_64.

The patch passes the regtest on aarch64, arm and x86_64.

OK for the trunk?


p.s. Note that x86_64 doesn't suffer from this issue as the corresponding widening multiply accumulate op is not available on the target.


        * tree-ssa-math-opts.c (convert_plusminus_to_widen): Call
        has_single_use () and not do the conversion if has_single_use ()
        returns false for the multiplication result.

Attachment: patch
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]