]> granicus.if.org Git - llvm/commit
[GlobalISel][AArch64] Fold G_SUB into G_ICMP when it's safe to do so
authorJessica Paquette <jpaquette@apple.com>
Mon, 17 Jun 2019 18:40:06 +0000 (18:40 +0000)
committerJessica Paquette <jpaquette@apple.com>
Mon, 17 Jun 2019 18:40:06 +0000 (18:40 +0000)
commit798f83b658242bef7b96d75368e987649bd39eb4
tree47e8238ab61a16427b7fb74077332cae2be359f0
parent6750ca7ad7952dfce15082339c98d7ec8df0f85c
[GlobalISel][AArch64] Fold G_SUB into G_ICMP when it's safe to do so

Basically porting over the behaviour in AArch64ISelLowering to GISel. See
emitComparison for reference.

When we have something like this:

```
  lhs = G_SUB 0, y
  ...
  G_ICMP lhs, rhs
```

We can fold away the G_SUB and produce a cmn instead, given that we produce
the same value in NZCV.

Add a test showing that the transformation works, and also showing that we
don't perform the transformation when it's unsafe.

Also factor out the CSet emission into emitCSetForICMP.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363596 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AArch64/AArch64InstructionSelector.cpp
test/CodeGen/AArch64/GlobalISel/opt-fold-cmn.mir [new file with mode: 0644]