diff options
| author | Geoff Berry <gberry@codeaurora.org> | 2016-02-29 19:53:22 +0000 |
|---|---|---|
| committer | Geoff Berry <gberry@codeaurora.org> | 2016-02-29 19:53:22 +0000 |
| commit | f5ba61d18cfae11f40ea6fd494c30b76c8494d4d (patch) | |
| tree | a5231b5c11e2c49ba92ea4307ae6d630a512e44a /llvm/test/CodeGen/AArch64 | |
| parent | fb2add2be1e00cd003c6c08d41285ca92fba5274 (diff) | |
| download | bcm5719-llvm-f5ba61d18cfae11f40ea6fd494c30b76c8494d4d.tar.gz bcm5719-llvm-f5ba61d18cfae11f40ea6fd494c30b76c8494d4d.zip | |
[AArch64] Fix isLegalAddImmediate() to return true for valid negative values.
Reviewers: t.p.northover, jmolloy
Subscribers: mcrosier, aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D17463
llvm-svn: 262248
Diffstat (limited to 'llvm/test/CodeGen/AArch64')
| -rw-r--r-- | llvm/test/CodeGen/AArch64/neg-imm.ll | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/AArch64/neg-imm.ll b/llvm/test/CodeGen/AArch64/neg-imm.ll new file mode 100644 index 00000000000..3ef0392397b --- /dev/null +++ b/llvm/test/CodeGen/AArch64/neg-imm.ll @@ -0,0 +1,46 @@ +; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s +; LSR used to pick a sub-optimal solution due to the target responding +; conservatively to isLegalAddImmediate for negative values. + +declare void @foo(i32) + +define void @test(i32 %px) { +; CHECK-LABEL: test: +; CHECK: // %entry +; CHECK: subs +; CHECK-NEXT: csel +entry: + %sub = add nsw i32 %px, -1 + %cmp = icmp slt i32 %px, 1 + %.sub = select i1 %cmp, i32 0, i32 %sub + br label %for.body + +for.body: +; CHECK: // %for.body +; CHECK: cmp +; CHECK-NEXT: b.eq +; CHECK: // %if.then3 + %x.015 = phi i32 [ %inc, %for.inc ], [ %.sub, %entry ] + %cmp2 = icmp eq i32 %x.015, %px + br i1 %cmp2, label %for.inc, label %if.then3 + +if.then3: + tail call void @foo(i32 %x.015) + br label %for.inc + +for.inc: +; CHECK: // %for.inc +; CHECK: add +; CHECK-NEXT: cmp +; CHECK: b.le +; CHECK: // %for.cond.cleanup + %inc = add nsw i32 %x.015, 1 + %cmp1 = icmp sgt i32 %x.015, %px + br i1 %cmp1, label %for.cond.cleanup.loopexit, label %for.body + +for.cond.cleanup.loopexit: + br label %for.cond.cleanup + +for.cond.cleanup: + ret void +} |

