summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorAsiri Rathnayake <asiri.rathnayake@arm.com>2015-10-19 11:44:24 +0000
committerAsiri Rathnayake <asiri.rathnayake@arm.com>2015-10-19 11:44:24 +0000
commit1040a53be3233c253da56210862eaea7ab06dee8 (patch)
tree107f6b9db7a1ad498afa7329251c0b5930d646e5 /llvm
parentb997792cc6ed531966e59515a389c98d176a93e2 (diff)
downloadbcm5719-llvm-1040a53be3233c253da56210862eaea7ab06dee8.tar.gz
bcm5719-llvm-1040a53be3233c253da56210862eaea7ab06dee8.zip
Fix mapping of @llvm.arm.ssat/usat intrinsics to ssat/usat instructions
The mapping of these two intrinsics in ARMInstrInfo.td had a small omission which lead to their operands not being validated/transformed before being lowered into usat and ssat instructions. This can cause incorrect instructions to be emitted. I've also added tests for the remaining two saturating arithmatic intrinsics @llvm.arm.qadd and @llvm.arm.qsub as they are missing codegen tests. llvm-svn: 250697
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/ARM/ARMInstrInfo.td8
-rw-r--r--llvm/test/CodeGen/ARM/sat-arith.ll60
-rw-r--r--llvm/test/CodeGen/ARM/ssat-lower.ll10
-rw-r--r--llvm/test/CodeGen/ARM/ssat-upper.ll10
-rw-r--r--llvm/test/CodeGen/ARM/usat-lower.ll10
-rw-r--r--llvm/test/CodeGen/ARM/usat-upper.ll10
6 files changed, 104 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.td b/llvm/lib/Target/ARM/ARMInstrInfo.td
index 93ade1343d9..9506e1ebef7 100644
--- a/llvm/lib/Target/ARM/ARMInstrInfo.td
+++ b/llvm/lib/Target/ARM/ARMInstrInfo.td
@@ -3678,10 +3678,10 @@ def USAT16 : AI<(outs GPRnopc:$Rd),
let Inst{3-0} = Rn;
}
-def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
- (SSAT imm:$pos, GPRnopc:$a, 0)>;
-def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
- (USAT imm:$pos, GPRnopc:$a, 0)>;
+def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
+ (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
+def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
+ (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
//===----------------------------------------------------------------------===//
// Bitwise Instructions.
diff --git a/llvm/test/CodeGen/ARM/sat-arith.ll b/llvm/test/CodeGen/ARM/sat-arith.ll
new file mode 100644
index 00000000000..c1ad1a5858e
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/sat-arith.ll
@@ -0,0 +1,60 @@
+; RUN: llc -O1 -mtriple=armv6-none-none-eabi %s -o - | FileCheck %s
+
+; CHECK-LABEL: qadd
+define i32 @qadd() nounwind {
+; CHECK: mov [[R0:.*]], #8
+; CHECK: mov [[R1:.*]], #128
+; CHECK: qadd [[R0]], [[R1]], [[R0]]
+ %tmp = call i32 @llvm.arm.qadd(i32 128, i32 8)
+ ret i32 %tmp
+}
+
+; CHECK-LABEL: qsub
+define i32 @qsub() nounwind {
+; CHECK: mov [[R0:.*]], #8
+; CHECK: mov [[R1:.*]], #128
+; CHECK: qsub [[R0]], [[R1]], [[R0]]
+ %tmp = call i32 @llvm.arm.qsub(i32 128, i32 8)
+ ret i32 %tmp
+}
+
+; upper-bound of the immediate argument
+; CHECK-LABEL: ssat1
+define i32 @ssat1() nounwind {
+; CHECK: mov [[R0:.*]], #128
+; CHECK: ssat [[R1:.*]], #32, [[R0]]
+ %tmp = call i32 @llvm.arm.ssat(i32 128, i32 32)
+ ret i32 %tmp
+}
+
+; lower-bound of the immediate argument
+; CHECK-LABEL: ssat2
+define i32 @ssat2() nounwind {
+; CHECK: mov [[R0:.*]], #128
+; CHECK: ssat [[R1:.*]], #1, [[R0]]
+ %tmp = call i32 @llvm.arm.ssat(i32 128, i32 1)
+ ret i32 %tmp
+}
+
+; upper-bound of the immediate argument
+; CHECK-LABEL: usat1
+define i32 @usat1() nounwind {
+; CHECK: mov [[R0:.*]], #128
+; CHECK: usat [[R1:.*]], #31, [[R0]]
+ %tmp = call i32 @llvm.arm.usat(i32 128, i32 31)
+ ret i32 %tmp
+}
+
+; lower-bound of the immediate argument
+; CHECK-LABEL: usat2
+define i32 @usat2() nounwind {
+; CHECK: mov [[R0:.*]], #128
+; CHECK: usat [[R1:.*]], #0, [[R0]]
+ %tmp = call i32 @llvm.arm.usat(i32 128, i32 0)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.arm.qadd(i32, i32) nounwind
+declare i32 @llvm.arm.qsub(i32, i32) nounwind
+declare i32 @llvm.arm.ssat(i32, i32) nounwind readnone
+declare i32 @llvm.arm.usat(i32, i32) nounwind readnone
diff --git a/llvm/test/CodeGen/ARM/ssat-lower.ll b/llvm/test/CodeGen/ARM/ssat-lower.ll
new file mode 100644
index 00000000000..a2cdfd87faa
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/ssat-lower.ll
@@ -0,0 +1,10 @@
+; RUN: not llc < %s -O1 -mtriple=armv6-none-none-eabi 2>&1 | FileCheck %s
+
+; immediate argument < lower-bound
+; CHECK: LLVM ERROR: Cannot select: intrinsic %llvm.arm.ssat
+define i32 @ssat1() nounwind {
+ %tmp = call i32 @llvm.arm.ssat(i32 128, i32 0)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.arm.ssat(i32, i32) nounwind readnone
diff --git a/llvm/test/CodeGen/ARM/ssat-upper.ll b/llvm/test/CodeGen/ARM/ssat-upper.ll
new file mode 100644
index 00000000000..bc4712b1994
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/ssat-upper.ll
@@ -0,0 +1,10 @@
+; RUN: not llc < %s -O1 -mtriple=armv6-none-none-eabi 2>&1 | FileCheck %s
+
+; immediate argument > upper-bound
+; CHECK: LLVM ERROR: Cannot select: intrinsic %llvm.arm.ssat
+define i32 @ssat1() nounwind {
+ %tmp = call i32 @llvm.arm.ssat(i32 128, i32 33)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.arm.ssat(i32, i32) nounwind readnone
diff --git a/llvm/test/CodeGen/ARM/usat-lower.ll b/llvm/test/CodeGen/ARM/usat-lower.ll
new file mode 100644
index 00000000000..c19cc9c39c4
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/usat-lower.ll
@@ -0,0 +1,10 @@
+; RUN: not llc < %s -O1 -mtriple=armv6-none-none-eabi 2>&1 | FileCheck %s
+
+; immediate argument < lower-bound
+; CHECK: LLVM ERROR: Cannot select: intrinsic %llvm.arm.usat
+define i32 @usat1() nounwind {
+ %tmp = call i32 @llvm.arm.usat(i32 128, i32 -1)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.arm.usat(i32, i32) nounwind readnone
diff --git a/llvm/test/CodeGen/ARM/usat-upper.ll b/llvm/test/CodeGen/ARM/usat-upper.ll
new file mode 100644
index 00000000000..d6e4a6fd534
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/usat-upper.ll
@@ -0,0 +1,10 @@
+; RUN: not llc < %s -O1 -mtriple=armv6-none-none-eabi 2>&1 | FileCheck %s
+
+; immediate argument > upper-bound
+; CHECK: LLVM ERROR: Cannot select: intrinsic %llvm.arm.usat
+define i32 @usat1() nounwind {
+ %tmp = call i32 @llvm.arm.usat(i32 128, i32 32)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.arm.usat(i32, i32) nounwind readnone
OpenPOWER on IntegriCloud