Bug 32378 - can't determine dependence (distinct sections of an array)
Summary: can't determine dependence (distinct sections of an array)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2007-06-17 15:35 UTC by tprince
Modified: 2012-07-16 13:02 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-06-21 23:32:19


Attachments
source code test case (197 bytes, text/plain)
2007-06-17 15:36 UTC, tprince
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tprince 2007-06-17 15:35:43 UTC
gfortran -O2  -ftree-vectorize -ftree-vectorizer-verbose=2 -c -v s174.f
The two sections of the array are clearly distinct, so it should be vectorized.
Comment 1 tprince 2007-06-17 15:36:33 UTC
Created attachment 13723 [details]
source code test case
Comment 2 tprince 2007-06-18 01:39:59 UTC
Performance change for full vectorization is not significant on Core 2 Duo; suggest reduced ;priority, apologies for submitting at normal severity
Comment 3 Andrew Pinski 2007-06-18 03:15:56 UTC
I think some of this is related to PR 32075.  (Looking into IR tells you that).
Comment 4 Dorit Naishlos 2007-06-18 11:08:42 UTC
I see this in the vectorizer dump file (with mainline from a few days ago):

(compute_affine_dependence
  (stmt_a =
D.1423_50 = (*a_49(D))[D.1422_48])
  (stmt_b =
(*a_49(D))[D.1420_51] = D.1425_54)
Data ref a:
(Data Ref:
  stmt: D.1423_50 = (*a_49(D))[D.1422_48];
  ref: (*a_49(D))[D.1422_48];
  base_object: (*a_49(D))[0];
  Access function 0: {pretmp.48_45 + 1, +, 1}_1
  Access function 1: 0B
)
Data ref b:
(Data Ref:
  stmt: (*a_49(D))[D.1420_51] = D.1425_54;
  ref: (*a_49(D))[D.1420_51];
  base_object: (*a_49(D))[0];
  Access function 0: {0, +, 1}_1
  Access function 1: 0B
)
affine dependence test not usable: access function not affine or constant.
(dependence classified: scev_not_known)
)
(compute_affine_dependence
  (stmt_a =
D.1424_53 = (*b_52(D))[D.1420_51])
  (stmt_b =
(*a_49(D))[D.1420_51] = D.1425_54)
)

(the IR looks a bit different than PR32075, but the data-rependence analysis fails with the same problem). pinskia - are you still planning to address this issue?
Comment 5 dorit 2007-07-01 12:43:43 UTC
Dependence analysis now fails with a different message:

(compute_affine_dependence
  (stmt_a =
D.1373_43 = (*a_42(D))[D.1372_41])
  (stmt_b =
(*a_42(D))[D.1370_44] = D.1375_47)
(subscript_dependence_tester
(analyze_overlapping_iterations
  (chrec_a = {pretmp.50_1 + 1, +, 1}_1)
  (chrec_b = {0, +, 1}_1)
(analyze_siv_subscript
siv test failed: unimplemented.
)
  (overlap_iterations_a = not known
)
  (overlap_iterations_b = not known
)
)
(dependence classified: scev_not_known)
)
)

Sebastian - any thughts/plans?
Comment 6 dorit 2007-08-19 13:47:10 UTC
> Sebastian - any thughts/plans?

Here's another testcase:

subroutine sub(aa,bb,n,m)
  implicit none
  integer, intent(in) :: n,m
  real, intent(inout) :: aa(n,m)
  real, intent(in)    :: bb(n,m)
  integer :: i,j
 do j= 2,n
    do i = 1,m
      aa(i,j)= aa(i,j-1)+bb(i,j-1)
    enddo
  enddo
end subroutine
end

Here too we get:

(compute_affine_dependence
  (stmt_a =
D.1385_55 = (*aa_54(D))[D.1384_53])
  (stmt_b =
(*aa_54(D))[D.1380_49] = D.1390_62)
(subscript_dependence_tester
(analyze_overlapping_iterations
  (chrec_a = {pretmp.34_76 + 1, +, 1}_2)
  (chrec_b = {pretmp.34_32 + 1, +, 1}_2)
(analyze_siv_subscript
siv test failed: unimplemented.
)
  (overlap_iterations_a = not known
)
  (overlap_iterations_b = not known
)
)
(dependence classified: scev_not_known)
)
)

Comment 7 Richard Biener 2012-07-16 13:02:49 UTC
Fixed - vectorized with versioning for aliasing (consider n == 4).  The
testcase from comment#6 is PR32375.