[llvm] ea8c186 - [InstCombine] add tests for pointer casts with insertelement; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 08:24:16 PDT 2020
Author: Sanjay Patel
Date: 2020-08-11T11:23:15-04:00
New Revision: ea8c186c408d45dba9ded06463046d5151495a40
URL: https://github.com/llvm/llvm-project/commit/ea8c186c408d45dba9ded06463046d5151495a40
DIFF: https://github.com/llvm/llvm-project/commit/ea8c186c408d45dba9ded06463046d5151495a40.diff
LOG: [InstCombine] add tests for pointer casts with insertelement; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/cast_ptr.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/cast_ptr.ll b/llvm/test/Transforms/InstCombine/cast_ptr.ll
index 500ef7f65423..3ac9acd0322b 100644
--- a/llvm/test/Transforms/InstCombine/cast_ptr.ll
+++ b/llvm/test/Transforms/InstCombine/cast_ptr.ll
@@ -161,3 +161,91 @@ entry:
%t4 = load i8, i8* %arrayidx223
ret i8 %t4
}
+
+define <2 x i32> @insertelt(<2 x i32> %x, i32* %p, i133 %index) {
+; CHECK-LABEL: @insertelt(
+; CHECK-NEXT: [[V:%.*]] = inttoptr <2 x i32> [[X:%.*]] to <2 x i32*>
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32*> [[V]], i32* [[P:%.*]], i133 [[INDEX:%.*]]
+; CHECK-NEXT: [[R:%.*]] = ptrtoint <2 x i32*> [[I]] to <2 x i32>
+; CHECK-NEXT: ret <2 x i32> [[R]]
+;
+ %v = inttoptr <2 x i32> %x to <2 x i32*>
+ %i = insertelement <2 x i32*> %v, i32* %p, i133 %index
+ %r = ptrtoint <2 x i32*> %i to <2 x i32>
+ ret <2 x i32> %r
+}
+
+define <2 x i32> @insertelt_intptr_trunc(<2 x i64> %x, i32* %p) {
+; CHECK-LABEL: @insertelt_intptr_trunc(
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i64> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[V:%.*]] = inttoptr <2 x i32> [[TMP1]] to <2 x i32*>
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32*> [[V]], i32* [[P:%.*]], i32 0
+; CHECK-NEXT: [[R:%.*]] = ptrtoint <2 x i32*> [[I]] to <2 x i32>
+; CHECK-NEXT: ret <2 x i32> [[R]]
+;
+ %v = inttoptr <2 x i64> %x to <2 x i32*>
+ %i = insertelement <2 x i32*> %v, i32* %p, i32 0
+ %r = ptrtoint <2 x i32*> %i to <2 x i32>
+ ret <2 x i32> %r
+}
+
+define <2 x i32> @insertelt_intptr_zext(<2 x i8> %x, i32* %p) {
+; CHECK-LABEL: @insertelt_intptr_zext(
+; CHECK-NEXT: [[TMP1:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[V:%.*]] = inttoptr <2 x i32> [[TMP1]] to <2 x i32*>
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32*> [[V]], i32* [[P:%.*]], i32 1
+; CHECK-NEXT: [[R:%.*]] = ptrtoint <2 x i32*> [[I]] to <2 x i32>
+; CHECK-NEXT: ret <2 x i32> [[R]]
+;
+ %v = inttoptr <2 x i8> %x to <2 x i32*>
+ %i = insertelement <2 x i32*> %v, i32* %p, i32 1
+ %r = ptrtoint <2 x i32*> %i to <2 x i32>
+ ret <2 x i32> %r
+}
+
+define <2 x i64> @insertelt_intptr_zext_zext(<2 x i8> %x, i32* %p) {
+; CHECK-LABEL: @insertelt_intptr_zext_zext(
+; CHECK-NEXT: [[TMP1:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[V:%.*]] = inttoptr <2 x i32> [[TMP1]] to <2 x i32*>
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32*> [[V]], i32* [[P:%.*]], i32 0
+; CHECK-NEXT: [[TMP2:%.*]] = ptrtoint <2 x i32*> [[I]] to <2 x i32>
+; CHECK-NEXT: [[R:%.*]] = zext <2 x i32> [[TMP2]] to <2 x i64>
+; CHECK-NEXT: ret <2 x i64> [[R]]
+;
+ %v = inttoptr <2 x i8> %x to <2 x i32*>
+ %i = insertelement <2 x i32*> %v, i32* %p, i32 0
+ %r = ptrtoint <2 x i32*> %i to <2 x i64>
+ ret <2 x i64> %r
+}
+
+declare void @use(<2 x i32*>)
+
+define <2 x i32> @insertelt_extra_use1(<2 x i32> %x, i32* %p) {
+; CHECK-LABEL: @insertelt_extra_use1(
+; CHECK-NEXT: [[V:%.*]] = inttoptr <2 x i32> [[X:%.*]] to <2 x i32*>
+; CHECK-NEXT: call void @use(<2 x i32*> [[V]])
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32*> [[V]], i32* [[P:%.*]], i32 0
+; CHECK-NEXT: [[R:%.*]] = ptrtoint <2 x i32*> [[I]] to <2 x i32>
+; CHECK-NEXT: ret <2 x i32> [[R]]
+;
+ %v = inttoptr <2 x i32> %x to <2 x i32*>
+ call void @use(<2 x i32*> %v)
+ %i = insertelement <2 x i32*> %v, i32* %p, i32 0
+ %r = ptrtoint <2 x i32*> %i to <2 x i32>
+ ret <2 x i32> %r
+}
+
+define <2 x i32> @insertelt_extra_use2(<2 x i32> %x, i32* %p) {
+; CHECK-LABEL: @insertelt_extra_use2(
+; CHECK-NEXT: [[V:%.*]] = inttoptr <2 x i32> [[X:%.*]] to <2 x i32*>
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32*> [[V]], i32* [[P:%.*]], i32 0
+; CHECK-NEXT: call void @use(<2 x i32*> [[I]])
+; CHECK-NEXT: [[R:%.*]] = ptrtoint <2 x i32*> [[I]] to <2 x i32>
+; CHECK-NEXT: ret <2 x i32> [[R]]
+;
+ %v = inttoptr <2 x i32> %x to <2 x i32*>
+ %i = insertelement <2 x i32*> %v, i32* %p, i32 0
+ call void @use(<2 x i32*> %i)
+ %r = ptrtoint <2 x i32*> %i to <2 x i32>
+ ret <2 x i32> %r
+}
More information about the llvm-commits
mailing list