[PATCH] D18838: [AArch64][CodeGen] Fix of incorrect peephole optimization in AArch64InstrInfo::optimizeCompareInstr

Evgeny Astigeevich via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 6 11:38:46 PDT 2016


eastig created this revision.
eastig added a reviewer: jmolloy.
eastig added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

AArch64InstrInfo::optimizeCompareInstr has bug PR27158 which causes generation of incorrect code. Details can be found here: https://llvm.org/bugs/show_bug.cgi?id=27158

# Fix:

* A condition code used after CmpInstr and before the next modification of NZCV is found. The optimization is not applied if different condition codes are used. It might be difficult to find a candidate for substitution to satisfy all of them. I think this case with multiple used condition codes does not happen often.
* Then it’s checked in 'canInstrSubstituteCmpInstr' that the instruction which defines a register for CmpInstr can produce the needed condition code itself or its S variant. If it or its S variant can produce then CmpInstr is removed.

# A regression test is added.
# A new test to check that SUBS is replaced by SUB is added.

http://reviews.llvm.org/D18838

Files:
  lib/Target/AArch64/AArch64InstrInfo.cpp
  test/CodeGen/AArch64/arm64-regress-opt-cmp.ll
  test/CodeGen/AArch64/subs-to-sub-opt.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18838.52827.patch
Type: text/x-patch
Size: 10378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160406/f2b23e4b/attachment.bin>


More information about the llvm-commits mailing list