summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@codeaurora.org>2016-10-26 18:15:32 +0000
committerChad Rosier <mcrosier@codeaurora.org>2016-10-26 18:15:32 +0000
commit0c621fda0d97b09fcc7699fdb3ce5350682ec3d4 (patch)
treea0a92f1e3c153ff009213ca234e69a6b50cc306d /llvm/test
parent0cd95447db38eb6f246f644d566e6eb06276ca1d (diff)
downloadbcm5719-llvm-0c621fda0d97b09fcc7699fdb3ce5350682ec3d4.tar.gz
bcm5719-llvm-0c621fda0d97b09fcc7699fdb3ce5350682ec3d4.zip
[AArch64] Avoid materializing constant 1 when generating cneg instructions.
Instead of cmp w0, #1 orr w8, wzr, #0x1 cneg w0, w8, ne we now generate cmp w0, #1 csinv w0, w0, wzr, eq PR28965 llvm-svn: 285217
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/AArch64/cond-sel-value-prop.ll11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/AArch64/cond-sel-value-prop.ll b/llvm/test/CodeGen/AArch64/cond-sel-value-prop.ll
index cc0aad1a0bf..0c8b5e559a3 100644
--- a/llvm/test/CodeGen/AArch64/cond-sel-value-prop.ll
+++ b/llvm/test/CodeGen/AArch64/cond-sel-value-prop.ll
@@ -97,3 +97,14 @@ define i64 @test9(i64 %x) {
%res = select i1 %cmp, i64 7, i64 -1
ret i64 %res
}
+
+; Rather than use a CNEG, use a CSINV to transform "a == 1 ? 1 : -1" to
+; "a == 1 ? a : -1" to avoid materializing a constant.
+; CHECK-LABEL: test10:
+; CHECK: cmp w[[REG:[0-9]]], #1
+; CHECK: cneg w0, w[[REG]], ne
+define i32 @test10(i32 %x) {
+ %cmp = icmp eq i32 %x, 1
+ %res = select i1 %cmp, i32 1, i32 -1
+ ret i32 %res
+}
OpenPOWER on IntegriCloud