powerpc/bpf/32: perform three operands ALU operations
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 1 Feb 2023 10:04:31 +0000 (11:04 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 10 Feb 2023 11:17:35 +0000 (22:17 +1100)
commit19daf0aef84f33bde9c742ed41b4ded567b8dfbf
tree25c281c9ee3166d4e0beb2c3a4e7145642dec9d2
parentc88da29b4d2ce8d0070646b8f99729e9b355a4bf
powerpc/bpf/32: perform three operands ALU operations

When an ALU instruction is preceded by a MOV instruction
that just moves a source register into the destination register of
the ALU, replace that MOV+ALU instructions by an ALU operation
taking the source of the MOV as second source instead of using its
destination.

Before the change, code could look like the following, with
superfluous separate register move (mr) instructions.

  70: 7f c6 f3 78  mr      r6,r30
  74: 7f a5 eb 78  mr      r5,r29
  78: 30 c6 ff f4  addic   r6,r6,-12
  7c: 7c a5 01 d4  addme   r5,r5

With this commit, addition instructions take r30 and r29 directly.

  70: 30 de ff f4  addic   r6,r30,-12
  74: 7c bd 01 d4  addme   r5,r29

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/b6719beaf01f9dcbcdbb787ef67c4a2f8e3a4cb6.1675245773.git.christophe.leroy@csgroup.eu
arch/powerpc/net/bpf_jit_comp32.c