]> granicus.if.org Git - llvm/commit
[AArch64] Improve code generation for logical instructions taking
authorAkira Hatanaka <ahatanaka@apple.com>
Fri, 21 Apr 2017 18:53:12 +0000 (18:53 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Fri, 21 Apr 2017 18:53:12 +0000 (18:53 +0000)
commit586c752a8267b3678236554d229cee7f85b9e86a
tree47b823708d092d75dcc279c6f4462abdd07acba5
parentbbc50e81b0fcd98fb169f10716dc2e1f068506be
[AArch64] Improve code generation for logical instructions taking
immediate operands.

This commit adds an AArch64 dag-combine that optimizes code generation
for logical instructions taking immediate operands. The optimization
uses demanded bits to change a logical instruction's immediate operand
so that the immediate can be folded into the immediate field of the
instruction.

This recommits r300932 and r300930, which was causing dag-combine to
loop forever. The problem was that optimizeLogicalImm was returning
true even when there was no change to the immediate node (which happened
when the immediate was all zeros or ones), which caused dag-combine to
push and pop the same node to the work list over and over again without
making any progress.

This commit fixes the bug by returning false early in optimizeLogicalImm
if the immediate is all zeros or ones. Also, it changes the code to
compare the immediate with 0 or Mask rather than calling
countPopulation.

rdar://problem/18231627

Differential Revision: https://reviews.llvm.org/D5591

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301019 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/Target/AArch64/AArch64ISelLowering.cpp
lib/Target/AArch64/AArch64ISelLowering.h
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
lib/Target/AMDGPU/SIISelLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/XCore/XCoreISelLowering.cpp
test/CodeGen/AArch64/optimize-imm.ll [new file with mode: 0644]