OSDN Git Service

[ARM] GlobalISel: Select hard G_FCMP for s32
authorDiana Picus <diana.picus@linaro.org>
Fri, 7 Jul 2017 08:39:04 +0000 (08:39 +0000)
committerDiana Picus <diana.picus@linaro.org>
Fri, 7 Jul 2017 08:39:04 +0000 (08:39 +0000)
commita479e53b5591700e2c8ffc28067c6f3a4c86ec79
treebad7b5af3e43b44ce5426ff82c8666a96e2c9c75
parentdc02fd0b4d23fd0fdbbce48cee872bf5ce97d841
[ARM] GlobalISel: Select hard G_FCMP for s32

We lower to a sequence consisting of:
- MOVi 0 into a register
- VCMPS to do the actual comparison and set the VFP flags
- FMSTAT to move the flags out of the VFP unit
- MOVCCi to either use the "zero register" that we have previously set
  with the MOVi, or move 1 into the result register, based on the values
  of the flags

As was the case with soft-float, for some predicates (one, ueq) we
actually need two comparisons instead of just one. When that happens, we
generate two VCMPS-FMSTAT-MOVCCi sequences and chain them by means of
using the result of the first MOVCCi as the "zero register" for the
second one. This is a bit overkill, since one comparison followed by
two non-flag-setting conditional moves should be enough. In any case,
the backend manages to CSE one of the comparisons away so it doesn't
matter much.

Note that unlike SelectionDAG and FastISel, we always use VCMPS, and not
VCMPES. This makes the code a lot simpler, and it also seems correct
since the LLVM Lang Ref defines simple true/false returns if the
operands are QNaN's. For SNaN's, even VCMPS throws an Invalid Operand
exception, so they won't be slipping through unnoticed.

Implementation-wise, this introduces a template so we can share the same
code that we use for handling integer comparisons, since the only
differences are in the details (exact opcodes to be used etc). Hopefully
this will be easy to extend to s64 G_FCMP.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307365 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMInstructionSelector.cpp
test/CodeGen/ARM/GlobalISel/arm-instruction-select-cmp.mir
test/CodeGen/ARM/GlobalISel/arm-isel-fp.ll