[PATCH] D129636: Fix a LSR debug invariance issue

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 04:36:14 PDT 2022


StephenTozer added a comment.

I think from the discussion so far, I would personally think the best answer would be to take the alternative route of modifying `getSCEV` to be able to not add items to the map when a flag `IsDebug` or such is added. It may be slightly difficult since `createSCEVIter` modifies the map as it recursively traverses the `Value`'s operands and uses the modifications to complete the requested SCEV. That problem is even worse for this solution however; suppose instead of `%inc`, the debug value referred to a value `%m = mul i32 %inc 2`; in that case, `getScev(%m)` would cache a SCEV expr for `%inc` along the way, and we wouldn't be calling `forgetValue` on it since it's not the value we requested! I'd say it's definitely better to have all the messiness confined to just `getSCEV` and make a slight interface modification personally. Though I'm also surprised that just adding something to the cache is modifying the output - I would have expected that the newly cached SCEV expr would be used only if necessary (i.e. we would otherwise need to generate instructions), and if it was necessary then SCEV would search for an expression regardless. Is this a bug in SCEV, or just a gap left for performance reasons?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129636/new/

https://reviews.llvm.org/D129636



More information about the llvm-commits mailing list