OSDN Git Service

bpf: Extends zero extension elimination beyond comparison instructions
authorYonghong Song <yhs@fb.com>
Tue, 13 Mar 2018 06:47:03 +0000 (06:47 +0000)
committerYonghong Song <yhs@fb.com>
Tue, 13 Mar 2018 06:47:03 +0000 (06:47 +0000)
commit5e02a7311a054a91c2453b695b9b7df3804963c3
treeaaadc4c0957557c56a254702d84297c45ff39687
parent83008ad941299d2054235a73e00d949e5b1f23eb
bpf: Extends zero extension elimination beyond comparison instructions

The current zero extension elimination was restricted to operands of
comparison. It actually could be extended to more cases.

For example:

  int *inc_p (int *p, unsigned a)
  {
    return p + a;
  }

'a' will be promoted to i64 during addition, and the zero extension could
be eliminated as well.

For the elimination optimization, it should be much better to start
recognizing the candidate sequence from the SRL instruction instead of J*
instructions.

This patch makes it an generic zero extension elimination pass instead of
one restricted with comparison.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327367 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/BPF/BPFMIPeephole.cpp
test/CodeGen/BPF/32-bit-subreg-peephole.ll