This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Try unsigned case value for switch to lookup table
AbandonedPublic

Authored by bcl5980 on Oct 14 2022, 12:07 PM.

Details

Summary

Treat case value as unsigned when we find the min case in the switch is min signed value and max case is max signed value.
And if the unsigned table need to check range, we still use the signed table.
Fix: #56538

Diff Detail

Event Timeline

bcl5980 created this revision.Oct 14 2022, 12:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 12:07 PM
bcl5980 requested review of this revision.Oct 14 2022, 12:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 12:07 PM
craig.topper added inline comments.Oct 14 2022, 4:01 PM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6373

Why not use isMaxSignedValue to be consistent with the use of isMinSignedValue?

bcl5980 marked an inline comment as done.Oct 14 2022, 6:10 PM
bcl5980 added inline comments.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6373

There is no isMaxSignedValue in Constant class.
isMaxSignedValue is on the APInt class.

bcl5980 planned changes to this revision.Oct 14 2022, 6:15 PM
bcl5980 marked an inline comment as done.

Need to fix other test failure.

craig.topper added inline comments.Oct 14 2022, 6:32 PM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6373

Then maybe use isMinValue here? Looks like isMinSignedValue() goes down to Constant which has to dyn_cast back to ConstantInt to call isMinValue.

bcl5980 updated this revision to Diff 467995.Oct 14 2022, 11:21 PM
bcl5980 edited the summary of this revision. (Show Details)Oct 14 2022, 11:23 PM
bcl5980 marked an inline comment as done.
bcl5980 abandoned this revision.Nov 23 2022, 6:15 PM