This is an archive of the discontinued LLVM Phabricator instance.

[ScalarEvolution] Skip values from unreachable bbs for phi ranges.
AbandonedPublic

Authored by fhahn on Nov 7 2022, 2:17 PM.

Details

Summary

Skip incoming value from unreachable blocks when computing ranges for
phis. Constructing SCEVs for values from unreachable blocks may lead to
violating assumptions based on dominance.

One example is the added LV test case. Here an assertion in GroupByComplexity
is triggered when constructing a SCEV for the incoming value from the unreachable
block because there's no dominance relation between 2 AddRecs.

It removes pr49856.ll because it is already part of
shift-recurrences.ll and needs updating.

Fixes #58811.

Diff Detail

Event Timeline

fhahn created this revision.Nov 7 2022, 2:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2022, 2:17 PM
fhahn requested review of this revision.Nov 7 2022, 2:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2022, 2:17 PM

The assertion from the bug report seems several levels removed from the top-level APIs; can we add an assertion somewhere a bit closer to the API misuse? I don't see a problem with this patch, exactly, but I'm not sure why the current code is wrong, as opposed to just being slightly suboptimal.

Do you mind giving more details on what assumption exactly was broken?

fhahn abandoned this revision.Apr 10 2023, 12:53 PM

I had another look and this patch didn't address the underlying issue properly, the problem is in the user of SCEV which tries to query partially constructed IR. I started working on a proper fix: D147965

llvm/lib/Analysis/ScalarEvolution.cpp