[PATCH] D117429: [AArch64] Revive optimize add/sub with immediate through MIPeepholeOpt

Micah Weston via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 16 07:18:09 PST 2022


red1bluelost created this revision.
red1bluelost added reviewers: dmgreen, benshi001, jaykang10.
Herald added subscribers: hiraditya, kristof.beyls.
red1bluelost requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixes the build issue with D111034 <https://reviews.llvm.org/D111034>, whose goal was to optimize
add/sub with long immediates.

Optimize ([add|sub] r, imm) -> ([ADD|SUB] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([add|sub] r, imm) -> ([SUB|ADD] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The change which fixed the build issue in D111034 <https://reviews.llvm.org/D111034> was the use of new virtual
registers so that SSA form is maintained until deleting MI.

Testing:

Tested by replicating the 2 stage bootstage process using QEMU and Docker,
replicating an AArch64 Linux environment. The steps for the build process
are taken from the "clang-aarch64-full-2stage" BuildBot.

Ran a 2 stage build on a clean LLVM repo to verify the environment.
Ran a 2 stage build on D111034 <https://reviews.llvm.org/D111034> which failed in when building stage 2.
Ran a 2 stage build of these changes and it built with no errors.

Notes on the Docker Environment:

To set up the environment, make sure to have QEMU and Docker installed then run 
the following commands:

  docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  docker run -it --entrypoint=/bin/bash linaro/ci-arm64-tcwg-llvmbot-ubuntu:bionic

I mounted my LLVM folder in the Docker container so that I could quickly edit
the source from my host environment.

Some of the tests will due to the QEMU environment, which I found when verifying
the clean branch of LLVM. These appear to mainly be associated with the
Compiler-RT, such as libFuzzer and some of the sanitizers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117429

Files:
  llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp
  llvm/test/CodeGen/AArch64/addsub.ll
  llvm/test/Transforms/CodeGenPrepare/AArch64/large-offset-gep.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117429.400378.patch
Type: text/x-patch
Size: 16107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220116/227c355b/attachment.bin>


More information about the llvm-commits mailing list