This is an archive of the discontinued LLVM Phabricator instance.

Do not short circuit hoistIVInc when recomputation of poison flags is needed.
ClosedPublic

Authored by resistor on Jan 1 2023, 9:29 PM.

Diff Detail

Event Timeline

resistor created this revision.Jan 1 2023, 9:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2023, 9:29 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
resistor requested review of this revision.Jan 1 2023, 9:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2023, 9:29 PM
nikic requested changes to this revision.Jan 2 2023, 1:58 AM
nikic added reviewers: fhahn, mkazantsev.
nikic added a subscriber: nikic.
nikic added inline comments.
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
1028–1029

We can't just fall through to the code below if RecomputePoisonFlags is set. This both does more than we need, and I believe it will produce broken IR in some cases, because it may end up moving the instruction down, making it no longer dominate other users.

I believe what you'd want to do is extract the poison flag handling code below and then call it in this short-circuit code path as well.

llvm/test/Transforms/IndVarSimplify/iv-poison.ll
5

Include a reference to PR59777 here (e.g. in a comment).

Instructions in tests should always be named, you can achieve this by running the test through -passes=instnamer.

This revision now requires changes to proceed.Jan 2 2023, 1:58 AM
resistor updated this revision to Diff 486151.Jan 3 2023, 7:54 PM

Extract poison fixup logic to a helper and apply it in the short-circuit case without
going through the rest of the hoisting process.

nikic added inline comments.Jan 4 2023, 2:47 AM
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
1044

nit: Should not be on one line.

1073–1074

Same

llvm/test/Transforms/IndVarSimplify/iv-poison.ll
5

Not addressed

nikic requested changes to this revision.Jan 9 2023, 3:14 AM

(For the nits, otherwise fine)

This revision now requires changes to proceed.Jan 9 2023, 3:14 AM
resistor updated this revision to Diff 487642.Jan 9 2023, 7:20 PM

Address review feedback.

nikic accepted this revision.Jan 10 2023, 1:21 AM

LGTM. This will be a minor compile-time regression, but it's a correctness fix...

This revision is now accepted and ready to land.Jan 10 2023, 1:21 AM
resistor updated this revision to Diff 488066.Jan 10 2023, 8:05 PM

Fix improperly updated testcase.

This revision was landed with ongoing or failed builds.Jan 10 2023, 10:03 PM
This revision was automatically updated to reflect the committed changes.