LLVM: lib/Analysis/ScalarEvolutionNormalization.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

18using namespace llvm;

19

20

21

29

30namespace {

31struct NormalizeDenormalizeRewriter

34

35

36

38

40 ScalarEvolution &SE)

41 : SCEVRewriteVisitor(SE), Kind(Kind),

42 Pred(Pred) {}

43 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr);

44};

45}

46

48NormalizeDenormalizeRewriter::visitAddRecExpr(const SCEVAddRecExpr *AR) {

50

52 [&](const SCEV *Op) { return visit(Op); });

53

54 if (!Pred(AR))

56

57

58

59

60

61

63

64

65

66 for (int i = 0, e = Operands.size() - 1; i < e; i++)

67 Operands[i] = SE.getAddExpr(Operands[i], Operands[i + 1]);

68 } else {

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90 for (int i = Operands.size() - 2; i >= 0; i--)

91 Operands[i] = SE.getMinusSCEV(Operands[i], Operands[i + 1]);

92 }

93

95}

96

100 bool CheckInvertible) {

101 if (Loops.empty())

102 return S;

105 };

106 const SCEV *Normalized =

107 NormalizeDenormalizeRewriter(Normalize, Pred, SE).visit(S);

109

110 if (CheckInvertible && Denormalized != S)

111 return nullptr;

112 return Normalized;

113}

114

117 return NormalizeDenormalizeRewriter(Normalize, Pred, SE).visit(S);

118}

119

123 if (Loops.empty())

124 return S;

127 };

128 return NormalizeDenormalizeRewriter(Denormalize, Pred, SE).visit(S);

129}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

TransformKind

TransformKind - Different types of transformations that TransformForPostIncUse can do.

Definition ScalarEvolutionNormalization.cpp:22

@ Normalize

Normalize - Normalize according to the given loops.

Definition ScalarEvolutionNormalization.cpp:24

@ Denormalize

Denormalize - Perform the inverse transform on the expression with the given loop set.

Definition ScalarEvolutionNormalization.cpp:27

This node represents a polynomial recurrence on the trip count of the specified loop.

const Loop * getLoop() const

ArrayRef< const SCEV * > operands() const

This visitor recursively visits a SCEV expression and re-writes it.

This class represents an analyzed expression in the program.

The main scalar evolution driver.

This is an optimization pass for GlobalISel generic memory operations.

OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)

Wrapper function around std::transform to apply a function to a range and store the result elsewhere.

LLVM_ABI const SCEV * denormalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops, ScalarEvolution &SE)

Denormalize S to be post-increment for all loops present in Loops.

Definition ScalarEvolutionNormalization.cpp:120

function_ref< bool(const SCEVAddRecExpr *)> NormalizePredTy

class LLVM_GSL_OWNER SmallVector

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...

LLVM_ABI const SCEV * normalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops, ScalarEvolution &SE, bool CheckInvertible=true)

Normalize S to be post-increment for all loops present in Loops.

Definition ScalarEvolutionNormalization.cpp:97

DWARFExpression::Operation Op

SmallPtrSet< const Loop *, 2 > PostIncLoopSet

LLVM_ABI const SCEV * normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred, ScalarEvolution &SE)

Normalize S for all add recurrence sub-expressions for which Pred returns true.

Definition ScalarEvolutionNormalization.cpp:115