[PATCH] D13857: Fix mapping of @llvm.arm.ssat/usat intrinsics to ssat/usat instructions
Asiri Rathnayake via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 02:14:10 PDT 2015
rmaprath created this revision.
rmaprath added reviewers: jmolloy, olista01.
rmaprath added a subscriber: llvm-commits.
rmaprath set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.
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 arithmetic intrinsics @llvm.arm.qadd and @llvm.arm.qsub as they are missing codegen tests.
Repository:
rL LLVM
http://reviews.llvm.org/D13857
Files:
lib/Target/ARM/ARMInstrInfo.td
test/CodeGen/ARM/sat-arith.ll
Index: test/CodeGen/ARM/sat-arith.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/sat-arith.ll
@@ -0,0 +1,40 @@
+; 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
+}
+
+; CHECK-LABEL: ssat
+define i32 @ssat() nounwind {
+; CHECK: mov [[R0:.*]], #128
+; CHECK: ssat [[R1:.*]], #8, [[R0]]
+ %tmp = call i32 @llvm.arm.ssat(i32 128, i32 8)
+ ret i32 %tmp
+}
+
+; CHECK-LABEL: usat
+define i32 @usat() nounwind {
+; CHECK: mov [[R0:.*]], #128
+; CHECK: usat [[R1:.*]], #8, [[R0]]
+ %tmp = call i32 @llvm.arm.usat(i32 128, i32 8)
+ 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
Index: lib/Target/ARM/ARMInstrInfo.td
===================================================================
--- lib/Target/ARM/ARMInstrInfo.td
+++ lib/Target/ARM/ARMInstrInfo.td
@@ -3678,10 +3678,10 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13857.37727.patch
Type: text/x-patch
Size: 2028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151019/f1d76a0d/attachment.bin>
More information about the llvm-commits
mailing list