This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Model simple same base pointer `select`s via `umin_seq`
AbandonedPublic

Authored by lebedev.ri on Apr 28 2022, 4:49 PM.

Details

Summary

We can't model pointer selects (or even fully variable integer selects) in SCEV in their generality.

But, *IFF* we are selecting between pointers with the same base object,
we can instead decompose the pointers into pointer base + integer offset,
try to model the select of said integer offsets, and add the result
to the base pointer, thus modelling the original select,
because we do support limited modelling for partially-variable integer selects.

Diff Detail

Event Timeline

lebedev.ri created this revision.Apr 28 2022, 4:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 4:49 PM

The general concept of modelling pointer selects as %base.ptr + (%cond ? %offset1 : %offset2) is pretty reasonable -- but the actual expressions produced for the integer select part are downright ridiculous. Is the SCEVExpander capable of reliably converting these back into a proper select? I feel like if this is something we want to model in SCEV, we should probably be adding a first-class select node.

mkazantsev added inline comments.May 10 2022, 2:15 AM
llvm/lib/Analysis/ScalarEvolution.cpp
6063

Does createNodeForSelectViaUMinSeq do anything useful for pointers? I guess it maybe an else-if then (with pointer check coming first).

lebedev.ri abandoned this revision.Oct 18 2022, 5:46 PM