This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] add nuw/nsw on BuildLookuptable BitMap shiftwidth calculation
ClosedPublic

Authored by khei4 on May 17 2023, 9:35 PM.

Details

Summary

When converting the switch to BitMap lookup table, its shift amount calculation is guaranteed to never overflow when deciding to use BitMap, on WouldFitInRegister.

This is part of https://reviews.llvm.org/D146903.

Diff Detail

Event Timeline

khei4 created this revision.May 17 2023, 9:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 9:35 PM
khei4 requested review of this revision.May 17 2023, 9:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 9:35 PM
khei4 updated this revision to Diff 523260.May 17 2023, 10:00 PM

update tests

nikic accepted this revision.May 18 2023, 7:10 AM

LGTM

llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6139

Does this comply with clang-format?

This revision is now accepted and ready to land.May 18 2023, 7:10 AM
khei4 added inline comments.May 18 2023, 10:03 PM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6139

Actually seems subtle, inserted newlines look optional, but I will remove them.
as

ShiftAmt = Builder.CreateMul(
    ShiftAmt, ConstantInt::get(MapTy, BitMapElementTy->getBitWidth()),
    "switch.shiftamt", /*HasNUW =*/true, /*HasNSW =*/true);

Thanks!

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