Details
- Reviewers
fhahn
Diff Detail
Event Timeline
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp | ||
---|---|---|
79 | Is the by-value pass here intentional? If so, should std::move be used in the initializer list? | |
188 | This is probably more accurately named IsKnownNonNegative. | |
232 | I'm wondering whether these should be sge and sle rather than sgt/slt. Edit: Hm, I guess MinSigned is excluded to avoid issues with various -1 multiplies? | |
244 | Hm, do we need an !IsSigned check here as well, as otherwise the base pointer + offset addition may overflow in a signed sense? | |
251 | Rather than checking for a specific GEP structure here, it might be more elegant to use accumulateConstantOffset() to handle any constant offset GEP? | |
269 | This precondition does not look correct. What if the inner GEP has more than one offset? What if it has a non-i8 element type? | |
308 | I think this condition can be incorrect if the index is truncating. For simplicity, maybe just reject indices of incorrect width? | |
316 | Ooops, this comment is outdated after recent changes. | |
400 | Are there any problems if Op1 is SIGNED_MIN here? | |
438 | Outdated comment. | |
508 | A bit odd that we only do this if the zero coefficients happen to be at the end. Edit: Ah, I guess we primarily care about determining whether there are no new variables at all here? | |
635 | I wonder whether this function is equivalent to DT.dominates(BasicBlockEdge(&BB, Succ), Succ)? | |
677 | Yeah, that would make more sense to me ... | |
690 | In this case, wouldn't a properlyDominates(&BB, Succ) check be sufficient? If we have something like assume; if() {A} B, then the assume holds in B. |
Thanks for taking a look! I pushed a couple of commits that addressed some points and also put up D139482.
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp | ||
---|---|---|
79 | Added std::move, but hopefully compilers should be able to generate good code after inlining even without it :) | |
188 | Renamed, thanks! | |
232 | Yeah, Val.sgt(MinSignedConstraintValue) ensures multiplying constants with -1 won't overflow. The upper bound could be sle. | |
244 | At the moment, this function isn't called for Signed, but I'll add an assert. I also added variants of the existing GEP tests but with signed predicates. | |
251 | I updated the code to use collectOffset here and instead of the loop over GEP indices below in | |
269 | Should be fixed in ee605b0accce by normalizing the offset. I tried various cases to see if I could construct a test case that fails verification without the condition, as inbounds GEPs shouldn't wrap around 0 when decrementing, hence we should be able to model this without the precondition I think. I'll plan to submit a patch for that separately. | |
308 | To my slight surprise, the implicit truncate preserves the signed value according to langref, so I think this should be fine? https://llvm.org/docs/LangRef.html#getelementptr-instruction
| |
316 | Updated in 6b940588a0fc, thanks! | |
400 | No, I think the only issue would be if we multiply SINGED_MIN constant with -1, but that's avoided above. If Op1 is SINGED_MIN here, it will be treated as variable. | |
438 | Will remove, thanks! | |
508 | Yep exactly, e.g. this is the case when one side adds and the other side subtracts the same value. | |
635 | Yep, updated, thanks! | |
677 | Updated in current main. | |
690 | This is not longer needed in the latest version after addressing the TODO above. |
Is the by-value pass here intentional? If so, should std::move be used in the initializer list?