[llvm] r358344 - [Tests] Add tests for D60659, and make adjustments to others to make diff clear
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 13 15:12:57 PDT 2019
Author: reames
Date: Sat Apr 13 15:12:56 2019
New Revision: 358344
URL: http://llvm.org/viewvc/llvm-project?rev=358344&view=rev
Log:
[Tests] Add tests for D60659, and make adjustments to others to make diff clear
Three related changes:
1) auto-gen several test files
2) Add the new tests at the bottom of said files
3) Adjust a couple of other test files not to use stores to constants when trying to test constexpr address handling
Modified:
llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll
llvm/trunk/test/Transforms/InstCombine/getelementptr.ll
llvm/trunk/test/Transforms/InstCombine/memcpy.ll
llvm/trunk/test/Transforms/InstCombine/memmove.ll
llvm/trunk/test/Transforms/InstCombine/memset.ll
llvm/trunk/test/Transforms/InstCombine/store.ll
Modified: llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll?rev=358344&r1=358343&r2=358344&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/gep-custom-dl.ll Sat Apr 13 15:12:56 2019
@@ -8,8 +8,7 @@ target datalayout = "e-m:m-p:40:64:64:32
%struct.C = type { [7 x i8] }
- at Global = constant [10 x i8] c"helloworld"
-
+ at Global = external global [10 x i8]
; Test that two array indexing geps fold
define i32* @test1(i32* %I) {
Modified: llvm/trunk/test/Transforms/InstCombine/getelementptr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/getelementptr.ll?rev=358344&r1=358343&r2=358344&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/getelementptr.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/getelementptr.ll Sat Apr 13 15:12:56 2019
@@ -9,8 +9,8 @@ target datalayout = "e-p:64:64-p1:16:16-
%struct.C = type { [7 x i8] }
- at Global = constant [10 x i8] c"helloworld"
- at Global_as1 = addrspace(1) constant [10 x i8] c"helloworld"
+ at Global = external global [10 x i8]
+ at Global_as1 = external addrspace(1) global [10 x i8]
; Test noop elimination
define i32* @test1(i32* %I) {
Modified: llvm/trunk/test/Transforms/InstCombine/memcpy.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memcpy.ll?rev=358344&r1=358343&r2=358344&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/memcpy.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/memcpy.ll Sat Apr 13 15:12:56 2019
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i1) nounwind
@@ -17,7 +18,7 @@ define void @test1(i8* %a) {
define void @test2(i8* %a) {
; CHECK-LABEL: @test2(
-; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %a, i32 100, i1 true)
+; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* [[A:%.*]], i8* [[A]], i32 100, i1 true)
; CHECK-NEXT: ret void
;
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %a, i32 100, i1 true)
@@ -28,10 +29,21 @@ define void @test2(i8* %a) {
define void @test3(i8* %d, i8* %s) {
; CHECK-LABEL: @test3(
-; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %d, i8* align 4 %s, i64 17179869184, i1 false)
+; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[D:%.*]], i8* align 4 [[S:%.*]], i64 17179869184, i1 false)
; CHECK-NEXT: ret void
;
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %d, i8* align 4 %s, i64 17179869184, i1 false)
ret void
}
+ at UnknownConstant = external constant i128
+
+define void @memcpy_to_constant(i8* %src) {
+; CHECK-LABEL: @memcpy_to_constant(
+; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 bitcast (i128* @UnknownConstant to i8*), i8* align 1 [[SRC:%.*]], i32 16, i1 false)
+; CHECK-NEXT: ret void
+;
+ %dest = bitcast i128* @UnknownConstant to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 16, i1 false)
+ ret void
+}
Modified: llvm/trunk/test/Transforms/InstCombine/memmove.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memmove.ll?rev=358344&r1=358343&r2=358344&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/memmove.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/memmove.ll Sat Apr 13 15:12:56 2019
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; This test makes sure that memmove instructions are properly eliminated.
;
; RUN: opt < %s -instcombine -S | FileCheck %s
@@ -8,30 +9,33 @@
@hello_u = constant [8 x i8] c"hello_u\00" ; <[8 x i8]*> [#uses=1]
define void @test1(i8* %A, i8* %B, i32 %N) {
- ;; CHECK-LABEL: test1
- ;; CHECK-NEXT: ret void
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: ret void
+;
call void @llvm.memmove.p0i8.p0i8.i32(i8* %A, i8* %B, i32 0, i1 false)
ret void
}
define void @test2(i8* %A, i32 %N) {
;; dest can't alias source since we can't write to source!
- ;; CHECK-LABEL: test2
- ;; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %A, i8* align 16 getelementptr inbounds ([33 x i8], [33 x i8]* @S, i{{32|64}} 0, i{{32|64}} 0), i32 %N, i1 false)
- ;; CHECK-NEXT: ret void
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[A:%.*]], i8* align 16 getelementptr inbounds ([33 x i8], [33 x i8]* @S, i64 0, i64 0), i32 [[N:%.*]], i1 false)
+; CHECK-NEXT: ret void
+;
call void @llvm.memmove.p0i8.p0i8.i32(i8* %A, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @S, i32 0, i32 0), i32 %N, i1 false)
ret void
}
define i32 @test3([1024 x i8]* %target) { ; arg: [1024 x i8]*> [#uses=1]
- ;; CHECK-LABEL: test3
- ;; CHECK-NEXT: [[P1:%[^\s]+]] = bitcast [1024 x i8]* %target to i16*
- ;; CHECK-NEXT: store i16 104, i16* [[P1]], align 2
- ;; CHECK-NEXT: [[P2:%[^\s]+]] = bitcast [1024 x i8]* %target to i32*
- ;; CHECK-NEXT: store i32 7103848, i32* [[P2]], align 4
- ;; CHECK-NEXT: [[P3:%[^\s]+]] = bitcast [1024 x i8]* %target to i64*
- ;; CHECK-NEXT: store i64 33037504440198504, i64* [[P3]], align 8
- ;; CHECK-NEXT: ret i32 0
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast [1024 x i8]* [[TARGET:%.*]] to i16*
+; CHECK-NEXT: store i16 104, i16* [[TMP1]], align 2
+; CHECK-NEXT: [[TMP2:%.*]] = bitcast [1024 x i8]* [[TARGET]] to i32*
+; CHECK-NEXT: store i32 7103848, i32* [[TMP2]], align 4
+; CHECK-NEXT: [[TMP3:%.*]] = bitcast [1024 x i8]* [[TARGET]] to i64*
+; CHECK-NEXT: store i64 33037504440198504, i64* [[TMP3]], align 8
+; CHECK-NEXT: ret i32 0
+;
%h_p = getelementptr [2 x i8], [2 x i8]* @h, i32 0, i32 0 ; <i8*> [#uses=1]
%hel_p = getelementptr [4 x i8], [4 x i8]* @hel, i32 0, i32 0 ; <i8*> [#uses=1]
%hello_u_p = getelementptr [8 x i8], [8 x i8]* @hello_u, i32 0, i32 0 ; <i8*> [#uses=1]
@@ -44,10 +48,24 @@ define i32 @test3([1024 x i8]* %target)
; PR2370
define void @test4(i8* %a) {
- ;; CHECK-LABEL: test4
- ;; CHECK-NEXT: ret void
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: ret void
+;
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %a, i8* %a, i32 100, i1 false)
ret void
}
+ at UnknownConstant = external constant i128
+
+define void @memmove_to_constant(i8* %src) {
+; CHECK-LABEL: @memmove_to_constant(
+; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i32(i8* align 4 bitcast (i128* @UnknownConstant to i8*), i8* align 1 [[SRC:%.*]], i32 16, i1 false)
+; CHECK-NEXT: ret void
+;
+ %dest = bitcast i128* @UnknownConstant to i8*
+ call void @llvm.memmove.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 16, i1 false)
+ ret void
+}
+
+
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) argmemonly nounwind
Modified: llvm/trunk/test/Transforms/InstCombine/memset.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset.ll?rev=358344&r1=358343&r2=358344&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/memset.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/memset.ll Sat Apr 13 15:12:56 2019
@@ -1,16 +1,18 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @test([1024 x i8]* %target) {
- ;; CHECK-LABEL: test
- ;; CHECK-NEXT: [[P1:%[^\s]+]] = getelementptr inbounds [1024 x i8], [1024 x i8]* %target, i64 0, i64 0
- ;; CHECK-NEXT: store i8 1, i8* [[P1]], align 1
- ;; CHECK-NEXT: [[P2:%[^\s]+]] = bitcast [1024 x i8]* %target to i16*
- ;; CHECK-NEXT: store i16 257, i16* [[P2]], align 2
- ;; CHECK-NEXT: [[P3:%[^\s]+]] = bitcast [1024 x i8]* %target to i32*
- ;; CHECK-NEXT: store i32 16843009, i32* [[P3]], align 4
- ;; CHECK-NEXT: [[P4:%[^\s]+]] = bitcast [1024 x i8]* %target to i64*
- ;; CHECK-NEXT: store i64 72340172838076673, i64* [[P4]], align 8
- ;; CHECK-NEXT: ret i32 0
+; CHECK-LABEL: @test(
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [1024 x i8], [1024 x i8]* [[TARGET:%.*]], i64 0, i64 0
+; CHECK-NEXT: store i8 1, i8* [[TMP1]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = bitcast [1024 x i8]* [[TARGET]] to i16*
+; CHECK-NEXT: store i16 257, i16* [[TMP2]], align 2
+; CHECK-NEXT: [[TMP3:%.*]] = bitcast [1024 x i8]* [[TARGET]] to i32*
+; CHECK-NEXT: store i32 16843009, i32* [[TMP3]], align 4
+; CHECK-NEXT: [[TMP4:%.*]] = bitcast [1024 x i8]* [[TARGET]] to i64*
+; CHECK-NEXT: store i64 72340172838076673, i64* [[TMP4]], align 8
+; CHECK-NEXT: ret i32 0
+;
%target_p = getelementptr [1024 x i8], [1024 x i8]* %target, i32 0, i32 0
call void @llvm.memset.p0i8.i32(i8* %target_p, i8 1, i32 0, i1 false)
call void @llvm.memset.p0i8.i32(i8* %target_p, i8 1, i32 1, i1 false)
@@ -20,4 +22,16 @@ define i32 @test([1024 x i8]* %target) {
ret i32 0
}
+ at Unknown = external constant i128
+
+define void @memset_to_constant() {
+; CHECK-LABEL: @memset_to_constant(
+; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 4 bitcast (i128* @Unknown to i8*), i8 0, i32 16, i1 false)
+; CHECK-NEXT: ret void
+;
+ %p = bitcast i128* @Unknown to i8*
+ call void @llvm.memset.p0i8.i32(i8* %p, i8 0, i32 16, i1 false)
+ ret void
+}
+
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1) argmemonly nounwind
Modified: llvm/trunk/test/Transforms/InstCombine/store.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/store.ll?rev=358344&r1=358343&r2=358344&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/store.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/store.ll Sat Apr 13 15:12:56 2019
@@ -291,6 +291,17 @@ define void @write_back7(i32* %p) {
ret void
}
+ at Unknown = external constant i32
+
+define void @store_to_constant() {
+; CHECK-LABEL: @store_to_constant(
+; CHECK-NEXT: store i32 0, i32* @Unknown, align 4
+; CHECK-NEXT: ret void
+;
+ store i32 0, i32* @Unknown
+ ret void
+}
+
!0 = !{!4, !4, i64 0}
!1 = !{!"omnipotent char", !2}
!2 = !{!"Simple C/C++ TBAA"}
More information about the llvm-commits
mailing list