This is an archive of the discontinued LLVM Phabricator instance.

[CGP] Freeze condition when despeculating ctlz/cttz
ClosedPublic

Authored by nikic on May 18 2022, 6:42 AM.

Details

Summary

Freeze the condition of the newly introduced conditional branch, to avoid immediate undefined behavior if the input to ctlz/cttz was originally poison.

Diff Detail

Event Timeline

nikic created this revision.May 18 2022, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2022, 6:42 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.May 18 2022, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2022, 6:42 AM
spatel accepted this revision.May 19 2022, 5:09 AM

LGTM - is it worth adding a CodeGen equivalent test to show that doesn't change (assuming there is no change)?

This revision is now accepted and ready to land.May 19 2022, 5:09 AM
fhahn accepted this revision.May 19 2022, 8:20 AM

LGTM, thanks!

llvm/lib/CodeGen/CodeGenPrepare.cpp
2042

nit: while you are here, llvm:: could be dropped.

2064

nit: might be worth to name the freeze adding a fr. prefix or something to the name of the frozen value.

nikic added a comment.May 23 2022, 1:56 AM

LGTM - is it worth adding a CodeGen equivalent test to show that doesn't change (assuming there is no change)?

It looks like we already have a couple of CodeGen tests for this, e.g. llvm/test/CodeGen/X86/clz.ll.

This revision was landed with ongoing or failed builds.May 23 2022, 2:01 AM
This revision was automatically updated to reflect the committed changes.
nikic marked 2 inline comments as done.