This is the first step to resolve the following issue, no-signed wrap flags propagation on SwitchToLookupTable.
https://github.com/llvm/llvm-project/issues/59671
motivated transformation: https://alive2.llvm.org/ce/z/GZs_dj
- add nsw/nuw on SwitchToLookupTable in SimplifyCFG
a. add nsw on SwitchToLookupTable index calculation on MinCaseVal subtraction <- this revision will be
https://alive2.llvm.org/ce/z/WSFRK5
b. add nuw/nsw on BuildLookuptable BitMap shiftwidth calculation https://reviews.llvm.org/D150838
https://alive2.llvm.org/ce/z/5Cmc72
c. add nsw on BuildLookuptable LinearMap calculation https://reviews.llvm.org/D150943
https://alive2.llvm.org/ce/z/cKBQfs
- preserve nsw on InstCombine for the cases. https://reviews.llvm.org/D152088
transformation: https://alive2.llvm.org/ce/z/ZWmZLv
Looking at how LinearMultiplier and LinearOffset are generated in SwitchLookupTable, I don't think that always setting NSW is correct. Nothing in the calculation suggests that it can't overflow. I believe we would have to track this separate when these values are computed. I also think that DefaultIsReachable doesn't matter for this part: At this point the range of the input values has already been checked.