[PATCH] D50079: [ARM] arm.assert.zeroext intrinsics
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 31 09:54:55 PDT 2018
samparker created this revision.
samparker added reviewers: SjoerdMeijer, dmgreen, efriedma, john.brawn, olista01.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.
Introduce two intrinsics which are then lowered in the backend to AssertZExt nodes. These can be inserted into the IR when the compiler knows that the given operand is already a zero extended i8 or i16.
https://reviews.llvm.org/D50079
Files:
include/llvm/IR/IntrinsicsARM.td
lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/assert-zeroext.ll
Index: test/CodeGen/ARM/assert-zeroext.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/assert-zeroext.ll
@@ -0,0 +1,45 @@
+; RUN: llc -mtriple=armv8 %s -o - | FileCheck %s
+; RUN: llc -mtriple=thumbv8m.main %s -o - | FileCheck %s
+
+; CHECK-LABEL: zero_i8
+; CHECK-NOT: uxt
+; CHECK: bx
+define zeroext i8 @zero_i8(i32 %arg) {
+entry:
+ %zeroext = call i32 @llvm.arm.assert.zeroext.i8(i32 %arg)
+ %trunc = trunc i32 %zeroext to i8
+ ret i8 %trunc
+}
+
+; CHECK-LABEL: zero_i8_mismatch
+; CHECK-NOT: uxt
+; CHECK: bx
+define zeroext i16 @zero_i8_mismatch(i32 %arg) {
+entry:
+ %zeroext = call i32 @llvm.arm.assert.zeroext.i8(i32 %arg)
+ %trunc = trunc i32 %zeroext to i16
+ ret i16 %trunc
+}
+
+; CHECK-LABEL: zero_i16
+; CHECK-NOT: uxt
+; CHECK: bx
+define zeroext i16 @zero_i16(i32 %arg) {
+entry:
+ %zeroext = call i32 @llvm.arm.assert.zeroext.i16(i32 %arg)
+ %trunc = trunc i32 %zeroext to i16
+ ret i16 %trunc
+}
+
+; CHECK-LABEL: zero_i16_mismatch
+; CHECK: uxtb r0, r0
+; CHECK: bx
+define zeroext i8 @zero_i16_mismatch(i32 %arg) {
+entry:
+ %zeroext = call i32 @llvm.arm.assert.zeroext.i16(i32 %arg)
+ %trunc = trunc i32 %zeroext to i8
+ ret i8 %trunc
+}
+
+declare i32 @llvm.arm.assert.zeroext.i8(i32)
+declare i32 @llvm.arm.assert.zeroext.i16(i32)
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -3376,6 +3376,12 @@
}
return Result;
}
+ case Intrinsic::arm_assert_zeroext_i8:
+ return DAG.getNode(ISD::AssertZext, dl, MVT::i32, Op->getOperand(1),
+ DAG.getValueType(MVT::i8));
+ case Intrinsic::arm_assert_zeroext_i16:
+ return DAG.getNode(ISD::AssertZext, dl, MVT::i32, Op->getOperand(1),
+ DAG.getValueType(MVT::i16));
case Intrinsic::arm_neon_vabs:
return DAG.getNode(ISD::ABS, SDLoc(Op), Op.getValueType(),
Op.getOperand(1));
Index: include/llvm/IR/IntrinsicsARM.td
===================================================================
--- include/llvm/IR/IntrinsicsARM.td
+++ include/llvm/IR/IntrinsicsARM.td
@@ -22,6 +22,13 @@
// and return value are essentially chains, used to force ordering during ISel.
def int_arm_space : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], []>;
+// Intrinsics for the compiler to use to assert that the operand is either a
+// i8 or i16 that is already zero extended.
+def int_arm_assert_zeroext_i8 :
+ Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem]>;
+def int_arm_assert_zeroext_i16 :
+ Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem]>;
+
// 16-bit multiplications
def int_arm_smulbb : GCCBuiltin<"__builtin_arm_smulbb">,
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50079.158310.patch
Type: text/x-patch
Size: 2876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180731/a220b12a/attachment.bin>
More information about the llvm-commits
mailing list