This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Do we need to do a loop invariant motion after loop interchange ?
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Li Jia He <helijia at linux dot ibm dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, Bill Schmidt <wschmidt at linux dot ibm dot com>, Segher Boessenkool <segher at kernel dot crashing dot org>
- Date: Thu, 21 Nov 2019 13:10:07 +0100
- Subject: Re: Do we need to do a loop invariant motion after loop interchange ?
- References: <33cbda5b-fad9-64c5-cba2-79ff347c814a@linux.ibm.com>
On Thu, Nov 21, 2019 at 10:22 AM Li Jia He <helijia@linux.ibm.com> wrote:
>
> Hi,
>
> I found for the follow code:
>
> #define N 256
> int a[N][N][N], b[N][N][N];
> int d[N][N], c[N][N];
> void __attribute__((noinline))
> double_reduc (int n)
> {
> for (int k = 0; k < n; k++)
> {
> for (int l = 0; l < n; l++)
> {
> c[k][l] = 0;
> for (int m = 0; m < n; m++)
> c[k][l] += a[k][m][l] * d[k][m] + b[k][m][l] * d[k][m];
> }
> }
> }
>
> I dumped the file after loop interchange and got the following information:
>
> <bb 3> [local count: 118111600]:
> # m_46 = PHI <0(7), m_45(11)>
> # ivtmp_44 = PHI <_42(7), ivtmp_43(11)>
> _39 = _49 + 1;
>
> <bb 4> [local count: 955630224]:
> # l_48 = PHI <0(3), l_47(12)>
> # ivtmp_41 = PHI <_39(3), ivtmp_40(12)>
> c_I_I_lsm.5_18 = c[k_28][l_48];
> c_I_I_lsm.5_53 = m_46 != 0 ? c_I_I_lsm.5_18 : 0;
> _2 = a[k_28][m_46][l_48];
> _3 = d[k_28][m_46];
> _4 = _2 * _3;
> _5 = b[k_28][m_46][l_48];
> _6 = _3 * _5;
> _7 = _4 + _6;
> _8 = _7 + c_I_I_lsm.5_53;
> c[k_28][l_48] = _8;
> l_47 = l_48 + 1;
> ivtmp_40 = ivtmp_41 - 1;
> if (ivtmp_40 != 0)
> goto <bb 12>; [89.00%]
> else
> goto <bb 5>; [11.00%]
>
> we can see '_3 = d[k_28][m_46];' is a loop invariant.
> Do we need to add a loop invariant motion pass after the loop interchange?
There is one at the end of the loop pipeline.
> BR,
> Lijia He
>