@@ -4108,36 +4108,38 @@ static bool scevUnconditionallyPropagatesPoisonFromOperands(SCEVTypes Kind) {
4108
4108
llvm_unreachable("Unknown SCEV kind!");
4109
4109
}
4110
4110
4111
- /// Return true if V is poison given that AssumedPoison is already poison.
4112
- static bool impliesPoison(const SCEV *AssumedPoison, const SCEV *S) {
4113
- // The only way poison may be introduced in a SCEV expression is from a
4114
- // poison SCEVUnknown (ConstantExprs are also represented as SCEVUnknown,
4115
- // not SCEVConstant). Notably, nowrap flags in SCEV nodes can *not*
4116
- // introduce poison -- they encode guaranteed, non-speculated knowledge.
4117
- //
4118
- // Additionally, all SCEV nodes propagate poison from inputs to outputs,
4119
- // with the notable exception of umin_seq, where only poison from the first
4120
- // operand is (unconditionally) propagated.
4121
- struct SCEVPoisonCollector {
4122
- bool LookThroughMaybePoisonBlocking;
4123
- SmallPtrSet<const SCEV *, 4> MaybePoison;
4124
- SCEVPoisonCollector(bool LookThroughMaybePoisonBlocking)
4125
- : LookThroughMaybePoisonBlocking(LookThroughMaybePoisonBlocking) {}
4126
-
4127
- bool follow(const SCEV *S) {
4128
- if (!LookThroughMaybePoisonBlocking &&
4129
- !scevUnconditionallyPropagatesPoisonFromOperands(S->getSCEVType()))
4130
- return false;
4111
+ namespace {
4112
+ // The only way poison may be introduced in a SCEV expression is from a
4113
+ // poison SCEVUnknown (ConstantExprs are also represented as SCEVUnknown,
4114
+ // not SCEVConstant). Notably, nowrap flags in SCEV nodes can *not*
4115
+ // introduce poison -- they encode guaranteed, non-speculated knowledge.
4116
+ //
4117
+ // Additionally, all SCEV nodes propagate poison from inputs to outputs,
4118
+ // with the notable exception of umin_seq, where only poison from the first
4119
+ // operand is (unconditionally) propagated.
4120
+ struct SCEVPoisonCollector {
4121
+ bool LookThroughMaybePoisonBlocking;
4122
+ SmallPtrSet<const SCEVUnknown *, 4> MaybePoison;
4123
+ SCEVPoisonCollector(bool LookThroughMaybePoisonBlocking)
4124
+ : LookThroughMaybePoisonBlocking(LookThroughMaybePoisonBlocking) {}
4125
+
4126
+ bool follow(const SCEV *S) {
4127
+ if (!LookThroughMaybePoisonBlocking &&
4128
+ !scevUnconditionallyPropagatesPoisonFromOperands(S->getSCEVType()))
4129
+ return false;
4131
4130
4132
- if (auto *SU = dyn_cast<SCEVUnknown>(S)) {
4133
- if (!isGuaranteedNotToBePoison(SU->getValue()))
4134
- MaybePoison.insert(S);
4135
- }
4136
- return true;
4131
+ if (auto *SU = dyn_cast<SCEVUnknown>(S)) {
4132
+ if (!isGuaranteedNotToBePoison(SU->getValue()))
4133
+ MaybePoison.insert(SU);
4137
4134
}
4138
- bool isDone() const { return false; }
4139
- };
4135
+ return true;
4136
+ }
4137
+ bool isDone() const { return false; }
4138
+ };
4139
+ } // namespace
4140
4140
4141
+ /// Return true if V is poison given that AssumedPoison is already poison.
4142
+ static bool impliesPoison(const SCEV *AssumedPoison, const SCEV *S) {
4141
4143
// First collect all SCEVs that might result in AssumedPoison to be poison.
4142
4144
// We need to look through potentially poison-blocking operations here,
4143
4145
// because we want to find all SCEVs that *might* result in poison, not only
@@ -4158,8 +4160,9 @@ static bool impliesPoison(const SCEV *AssumedPoison, const SCEV *S) {
4158
4160
4159
4161
// Make sure that no matter which SCEV in PC1.MaybePoison is actually poison,
4160
4162
// it will also make S poison by being part of PC2.MaybePoison.
4161
- return all_of(PC1.MaybePoison,
4162
- [&](const SCEV *S) { return PC2.MaybePoison.contains(S); });
4163
+ return all_of(PC1.MaybePoison, [&](const SCEVUnknown *S) {
4164
+ return PC2.MaybePoison.contains(S);
4165
+ });
4163
4166
}
4164
4167
4165
4168
const SCEV *
0 commit comments