summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-07-04 16:35:41 +0000
committerJames Molloy <james.molloy@arm.com>2016-07-04 16:35:41 +0000
commit9f019835ef824cc22e49e8deeb48e2722f013642 (patch)
tree2b5686682a659567bfe4b0d770d12ec860a4ad58 /llvm/test/CodeGen
parent7f8d6dc0efc43577f64e1f2ebb39a0366820c51a (diff)
downloadbcm5719-llvm-9f019835ef824cc22e49e8deeb48e2722f013642.tar.gz
bcm5719-llvm-9f019835ef824cc22e49e8deeb48e2722f013642.zip
[Thumb] Reapply r272251 with a fix for PR28348
We were using DAG->getConstant instead of DAG->getTargetConstant. This meant that we could inadvertently increase the use count of a constant if stars aligned, which it did in this testcase. Increasing the use count of the constant could cause ISel to fall over (because DAGToDAG lowering assumed the constant had only one use!) Original commit message: [Thumb] Select a BIC instead of AND if the immediate can be encoded more optimally negated If an immediate is only used in an AND node, it is possible that the immediate can be more optimally materialized when negated. If this is the case, we can negate the immediate and use a BIC instead; int i(int a) { return a & 0xfffffeec; } Used to produce: ldr r1, [CONSTPOOL] ands r0, r1 CONSTPOOL: 0xfffffeec And now produces: movs r1, #255 adds r1, #20 ; Less costly immediate generation bics r0, r1 llvm-svn: 274510
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/Thumb/bic_imm.ll12
-rw-r--r--llvm/test/CodeGen/Thumb2/bicbfi.ll17
2 files changed, 29 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/Thumb/bic_imm.ll b/llvm/test/CodeGen/Thumb/bic_imm.ll
new file mode 100644
index 00000000000..078c321b781
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb/bic_imm.ll
@@ -0,0 +1,12 @@
+; RUN: llc < %s -mtriple=thumbv7-linux-gnueabi -mcpu=cortex-m0 -verify-machineinstrs | FileCheck --check-prefix CHECK-T1 %s
+; RUN: llc < %s -mtriple=thumbv7-linux-gnueabi -mcpu=cortex-m3 -verify-machineinstrs | FileCheck --check-prefix CHECK-T2 %s
+
+; CHECK-T1-LABEL: @i
+; CHECK-T2-LABEL: @i
+; CHECK-T1: bics r0, #275
+; CHECK-T2: bic r0, r0, #275
+define i32 @i(i32 %a) {
+entry:
+ %and = and i32 %a, -276
+ ret i32 %and
+}
diff --git a/llvm/test/CodeGen/Thumb2/bicbfi.ll b/llvm/test/CodeGen/Thumb2/bicbfi.ll
new file mode 100644
index 00000000000..fcdb1225db5
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb2/bicbfi.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv7--linux-gnueabihf"
+
+; CHECK-LABEL: f:
+; CHECK: bic
+define void @f(i32* nocapture %b, i32* nocapture %c, i32 %a) {
+ %1 = and i32 %a, -4096
+ store i32 %1, i32* %c, align 4
+ %2 = and i32 %a, 4095
+ %3 = or i32 %2, 4096
+ %4 = load i32, i32* %b, align 4
+ %5 = add nsw i32 %4, %3
+ store i32 %5, i32* %b, align 4
+ ret void
+} \ No newline at end of file
OpenPOWER on IntegriCloud