This is an archive of the discontinued LLVM Phabricator instance.

[PATCH 16/27] [noalias] Clone scopes and llvm.noalias.decl when unrolling.
Needs ReviewPublic

Authored by jeroen.dobbelaere on Oct 4 2019, 3:06 PM.

Details

Reviewers
hfinkel
jdoerfert
Summary

This is part of the series started by D68484.

Restrict variables that are declared inside a loop must get
an unique scope when the loop body is unrolled.

Note: this is a stable point and tests should run fine with the patches applied up to this point.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2019, 3:06 PM
marksl added a subscriber: marksl.Mar 26 2020, 2:56 PM

I assume that a similar fix would then be necessary for loop peeling (and any such loop optimization that clones blocks).

I assume that a similar fix would then be necessary for loop peeling (and any such loop optimization that clones blocks).

Yes. Whenever a body that contains a restrict declaration (llvm.noalias.decl), care must be taken to handle the associated noalias scope in a correct way:

  • when the cloning is done because of 'unrolling' (or peeling), the scopes associated to those declarations must be made unique (aka, each iteration has its own scope)
    • As D68511 shows, loop rotation is more complicated, as only parts of a body are duplicated..
  • when the cloning is done for efficiency of different code paths (loop unswitching could be a good example here), both versions can (re)use the same scope.
    • Note: it would also be valid to uniquify them, but it is not needed for correctness.
danilaml added inline comments.
llvm/lib/Transforms/Utils/NoAliasUtils.cpp
174 ↗(On Diff #226809)

SNAN name can conflict with SNAN macro in math.h

jeroen.dobbelaere retitled this revision from [PATCH 27/38] [noalias] Clone scopes and llvm.noalias.decl when unrolling. to [PATCH 16/26] [noalias] Clone scopes and llvm.noalias.decl when unrolling..
jeroen.dobbelaere retitled this revision from [PATCH 16/26] [noalias] Clone scopes and llvm.noalias.decl when unrolling. to [PATCH 16/27] [noalias] Clone scopes and llvm.noalias.decl when unrolling..

Rebased to 9fb46a452d4e5666828c95610ceac8dcd9e4ce16 (September 7, 2020)