1//===---- AlignmentFromAssumptions.h ----------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements a ScalarEvolution-based transformation to set
11// the alignments of load, stores and memory intrinsics based on the truth
12// expressions of assume intrinsics. The primary motivation is to handle
13// complex alignment assumptions that apply to vector loads and stores that
14// appear after vectorization and unrolling.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_TRANSFORMS_SCALAR_ALIGNMENTFROMASSUMPTIONS_H
19#define LLVM_TRANSFORMS_SCALAR_ALIGNMENTFROMASSUMPTIONS_H
20
21#include "llvm/Analysis/ScalarEvolution.h"
22#include "llvm/IR/Function.h"
23#include "llvm/IR/IntrinsicInst.h"
24#include "llvm/IR/PassManager.h"
25
26namespace llvm {
27
28struct AlignmentFromAssumptionsPass
29    : public PassInfoMixin<AlignmentFromAssumptionsPass> {
30  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
31
32  // Glue for old PM.
33  bool runImpl(Function &F, AssumptionCache &AC, ScalarEvolution *SE_,
34               DominatorTree *DT_);
35
36  // For memory transfers, we need a common alignment for both the source and
37  // destination. If we have a new alignment for only one operand of a transfer
38  // instruction, save it in these maps.  If we reach the other operand through
39  // another assumption later, then we may change the alignment at that point.
40  DenseMap<MemTransferInst *, unsigned> NewDestAlignments, NewSrcAlignments;
41
42  ScalarEvolution *SE = nullptr;
43  DominatorTree *DT = nullptr;
44
45  bool extractAlignmentInfo(CallInst *I, Value *&AAPtr, const SCEV *&AlignSCEV,
46                            const SCEV *&OffSCEV);
47  bool processAssumption(CallInst *I);
48};
49}
50
51#endif // LLVM_TRANSFORMS_SCALAR_ALIGNMENTFROMASSUMPTIONS_H
52