[PATCH] Optimize redundant insertvalue instructions

Michael Zolotukhin mzolotukhin at apple.com
Tue May 6 11:00:46 PDT 2014


The first one formally isn’t dead, because its result is used in the second (the first argument). The patch actually allows considering it dead.

I’m trying to reproduce this in a small C/C++ test, but that’s not that easy.

Thanks,
Michael

On May 6, 2014, at 9:24 PM, Eric Christopher <echristo at gmail.com> wrote:

> This is weird, how'd we get here? How aren't we deleting the first one
> as dead code? Etc.
> 
> -eric
> 
> On Tue, May 6, 2014 at 7:42 AM, Michael Zolotukhin
> <mzolotukhin at apple.com> wrote:
>> Hi,
>> 
>> This patch implements a simple optimization of redundant insertvalue
>> instructions.
>> 
>> Here is a small example where it will help:
>>  %0 = insertvalue { i8, i32 } undef, i8 %x, 0
>>  %1 = insertvalue { i8, i32 } %0,    i8 %y, 0
>> 
>> In this example, the second instruction inserts values at the same indices,
>> as the first one, and consequently, the first instruction is redundant.
>> This code will be transformed to:
>>  %0 = insertvalue { i8, i32 } undef, i8 %y, 0
>> 
>> This optimization catches nothing on specs and test-suite, but the example
>> was inspired by a real world application.
>> 
>> As an experiment, I tried a more sophisticated implementation, which was
>> capable of dealing with several users and with partially overlapping
>> indices, but that also caught nothing on specs (and for my application the
>> simple version was enough). If there is an interest, I could share a patch
>> with this more complicated implementation as well.
>> 
>> Is it ok to commit this patch?
>> 
>> 
>> 
>> Thanks,
>> Michael
>> 
>> _______________________________________________
>> 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