[PATCH] Optimize redundant insertvalue instructions

Michael Zolotukhin mzolotukhin at apple.com
Tue May 6 07:42:12 PDT 2014


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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140506/05dd2064/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: redundant-insertvalue.patch
Type: application/octet-stream
Size: 3190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140506/05dd2064/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140506/05dd2064/attachment-0001.html>

More information about the llvm-commits mailing list