[PATCH] InstCombine: Narrow switch instruction operands using known bits

Akira Hatanaka ahatanak at gmail.com
Wed Oct 8 18:35:43 PDT 2014

This patch adds an inst-combine optimization which narrows the operands of a switch instruction if the upper bits are known to be all 1 or 0.

For example, since the upper 32-bits are all zero in the following switch instruction,

%and = and i64 %a, 4294967295
switch i64 %and, label %sw.default [
  i64 10, label %return
  i64 100, label %sw.bb1
  i64 1001, label %sw.bb2

we can turn it into a 32-bit instruction:

switch i32 %and, label %sw.default [
  i32 10, label %return
  i32 100, label %sw.bb1
  i32 1001, label %sw.bb2


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5691.14610.patch
Type: text/x-patch
Size: 3446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141009/63e8ec29/attachment.bin>

More information about the llvm-commits mailing list