]> granicus.if.org Git - llvm/commit
[Thumb] Add support for tMUL in the compare instruction peephole optimizer.
authorSjoerd Meijer <sjoerd.meijer@arm.com>
Fri, 20 Jan 2017 13:10:12 +0000 (13:10 +0000)
committerSjoerd Meijer <sjoerd.meijer@arm.com>
Fri, 20 Jan 2017 13:10:12 +0000 (13:10 +0000)
commit360cd34a8230b9a43a005d7949cbe1703970432d
treeff94cbac59820cfc4e479173eecc3eba0a1fd40c
parent0a1c1b20e260bb44dc679353bc8e6feb7fce7ab2
[Thumb] Add support for tMUL in the compare instruction peephole optimizer.

We also want to optimise tests like this: return a*b == 0.  The MULS
instruction is flag setting, so we don't need the CMP instruction but can
instead branch on the result of the MULS. The generated instructions sequence
for this example was: MULS, MOVS, MOVS, CMP. The MOVS instruction load the
boolean values resulting from the select instruction, but these MOVS
instructions are flag setting and were thus preventing this optimisation. Now
we first reorder and move the MULS to before the CMP and generate sequence
MOVS, MOVS, MULS, CMP so that the optimisation could trigger. Reordering of the
MULS and MOVS is safe to do because the subsequent MOVS instructions just set
the CPSR register and don't use it, i.e. the CPSR is dead.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292608 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMBaseInstrInfo.cpp
test/CodeGen/ARM/cmp1-peephole-thumb.mir [new file with mode: 0644]
test/CodeGen/ARM/cmp2-peephole-thumb.mir [new file with mode: 0644]