[llvm-commits] [Patch] Switch-to-lookup tables: do simple constant propagation

Hans Wennborg hans at chromium.org
Wed Oct 31 06:43:57 PDT 2012


Thanks, Evan! Landed r167115.

 - Hans

On Tue, Oct 30, 2012 at 10:00 PM, Evan Cheng <evan.cheng at apple.com> wrote:
> LGTM
>
> evan
>
> On Oct 29, 2012, at 10:54 AM, Hans Wennborg <hans at chromium.org> wrote:
>
>> On Wed, Oct 10, 2012 at 9:55 AM, Hans Wennborg <hans at chromium.org> wrote:
>>> On Wed, Oct 3, 2012 at 1:51 PM, Duncan Sands <baldrick at free.fr> wrote:
>>>>
>>>>> A patch [1] by Craig earlier this week pointed out that Clang fails to
>>>>> build lookup tables for switches like this:
>>>>>
>>>>>   switch(x) {
>>>>>     case 1: return 5;
>>>>>     case 2: return 42;
>>>>>     case 3: case 4: case 5:
>>>>>       return x - 123;
>>>>>     default: return 123;
>>>>>   }
>>>>>
>>>>> Where the resulting value for the 3, 4, 5 cases is "x - 123", rather
>>>>> than a constant.
>>>>
>>>>
>>>> maybe it is better to do this as part of some more generic switch
>>>> simplification
>>>> logic rather than during table construction.
>>>
>>> We chatted about this on IRC last week, and I think we concluded that
>>> it seemed hard to determine when it would be profitable to do this
>>> transformation in general, and that it probably made sense to just do
>>> it when forming lookup tables.
>>>
>>> If so, I'd like to move forward with this patch.
>>>
>>> Does anyone have comments on the constant propagation code itself?
>>> Does it look sensible, or are there any utility functions I could
>>> reuse?
>>
>> Ping? Attaching a rebased patch for convenience.
>>
>> Thanks,
>> Hans
>> <switch_table_const_prop2.patch>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list