During the guard widening we can add a poison use in the first guard which
can result in undefined behavior which were not before due to this guard could
guards us from it.
To avoid this behavior we can use freeze instruction.
Paths
| Differential D128155
[GuardWidening] Use freeze to widen using possible poison value. AbandonedPublic Authored by skatkov on Jun 19 2022, 11:20 PM.
Details
Summary During the guard widening we can add a poison use in the first guard which To avoid this behavior we can use freeze instruction.
Diff Detail Event TimelineRKSimon retitled this revision from [GuardWindening] Use freeze to widen using possible poison value. to [GuardWidening] Use freeze to widen using possible poison value..Jun 20 2022, 11:01 AM Comment Actions
Do we have logical and? Comment Actions
Also, IRBuilder::CreateLogicalAnd Comment Actions I tend to re-write the patch and introduce the option to use freeze or logical and then choose the best one. Thank you, guys for suggestions. skatkov mentioned this in D128322: [GuardWidening] Use logical and in widenCondCommon as it stated in doc.Jun 21 2022, 10:54 PM Comment ActionsPlease take a look the alternative solution with logical and: https://reviews.llvm.org/D128322 Comment Actions I come up with this version of the solution. Dear reviewers, I would appreciate the review. Comment Actions
Guard Widening uses two main ways to wide the current guard. The first case is more complex. Later optimization consider all Bi + OFFi < Li and split them into groups where Bi and Li are equal. After all groups are processed we combine all checks with arithmetic and operation but freeze those elements which require this. I hope it helps. This revision is now accepted and ready to land.Dec 8 2022, 9:04 PM
Revision Contents
Diff 438260 llvm/lib/Transforms/Scalar/GuardWidening.cpp
llvm/test/Transforms/GuardWidening/basic-loop.ll
llvm/test/Transforms/GuardWidening/basic.ll
llvm/test/Transforms/GuardWidening/basic_widenable_condition_guards.ll
llvm/test/Transforms/GuardWidening/loop-schedule.ll
llvm/test/Transforms/GuardWidening/mixed_guards.ll
llvm/test/Transforms/GuardWidening/range-check-merging.ll
|
It seems it would be sufficient to only freeze the final value?