2009-10-21 04:39:43 +08:00
|
|
|
; RUN: opt < %s -ipsccp -S | FileCheck %s
|
2004-12-10 15:54:51 +08:00
|
|
|
|
2009-10-21 04:39:43 +08:00
|
|
|
;;======================== test1
|
|
|
|
|
|
|
|
define internal i32 @test1a(i32 %A) {
|
|
|
|
%X = add i32 1, 2
|
2008-03-19 12:14:49 +08:00
|
|
|
ret i32 %A
|
2004-12-10 15:54:51 +08:00
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define internal i32 @test1a(
|
2009-10-21 04:39:43 +08:00
|
|
|
; CHECK: ret i32 undef
|
|
|
|
|
|
|
|
define i32 @test1b() {
|
|
|
|
%X = call i32 @test1a( i32 17 )
|
|
|
|
ret i32 %X
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @test1b(
|
2009-10-21 04:39:43 +08:00
|
|
|
; CHECK: ret i32 17
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;======================== test2
|
|
|
|
|
|
|
|
define internal i32 @test2a(i32 %A) {
|
|
|
|
%C = icmp eq i32 %A, 0
|
|
|
|
br i1 %C, label %T, label %F
|
|
|
|
T:
|
|
|
|
%B = call i32 @test2a( i32 0 )
|
|
|
|
ret i32 0
|
|
|
|
F:
|
|
|
|
%C.upgrd.1 = call i32 @test2a(i32 1)
|
|
|
|
ret i32 %C.upgrd.1
|
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define internal i32 @test2a(
|
2009-10-21 04:39:43 +08:00
|
|
|
; CHECK-NEXT: br label %T
|
|
|
|
; CHECK: ret i32 undef
|
|
|
|
|
2004-12-10 15:54:51 +08:00
|
|
|
|
2009-10-21 04:39:43 +08:00
|
|
|
define i32 @test2b() {
|
|
|
|
%X = call i32 @test2a(i32 0)
|
2008-03-19 12:14:49 +08:00
|
|
|
ret i32 %X
|
2004-12-10 15:54:51 +08:00
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @test2b(
|
2009-10-21 04:39:43 +08:00
|
|
|
; CHECK-NEXT: %X = call i32 @test2a(i32 0)
|
|
|
|
; CHECK-NEXT: ret i32 0
|
|
|
|
|
|
|
|
|
|
|
|
;;======================== test3
|
|
|
|
|
|
|
|
@G = internal global i32 undef
|
2008-03-19 12:14:49 +08:00
|
|
|
|
2009-10-21 04:39:43 +08:00
|
|
|
define void @test3a() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%X = load i32, i32* @G
|
2009-10-21 04:39:43 +08:00
|
|
|
store i32 %X, i32* @G
|
|
|
|
ret void
|
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test3a(
|
2009-10-21 04:39:43 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
|
|
|
|
|
|
|
|
define i32 @test3b() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%V = load i32, i32* @G
|
2009-10-21 04:39:43 +08:00
|
|
|
%C = icmp eq i32 %V, 17
|
|
|
|
br i1 %C, label %T, label %F
|
|
|
|
T:
|
|
|
|
store i32 17, i32* @G
|
|
|
|
ret i32 %V
|
|
|
|
F:
|
|
|
|
store i32 123, i32* @G
|
|
|
|
ret i32 0
|
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @test3b(
|
2009-10-21 04:39:43 +08:00
|
|
|
; CHECK-NOT: store
|
|
|
|
; CHECK: ret i32 0
|
2009-10-21 05:00:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
;;======================== test4
|
|
|
|
|
|
|
|
define internal {i64,i64} @test4a() {
|
|
|
|
%a = insertvalue {i64,i64} undef, i64 4, 1
|
|
|
|
%b = insertvalue {i64,i64} %a, i64 5, 0
|
|
|
|
ret {i64,i64} %b
|
|
|
|
}
|
|
|
|
|
2016-07-14 10:51:41 +08:00
|
|
|
; CHECK-LABEL: define internal { i64, i64 } @test4a(
|
2016-07-21 04:17:13 +08:00
|
|
|
; CHECK-NEXT: ret { i64, i64 } undef
|
2016-07-14 10:51:41 +08:00
|
|
|
; CHECK-NEXT: }
|
|
|
|
|
2015-06-18 04:52:32 +08:00
|
|
|
define i64 @test4b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2009-10-21 05:00:47 +08:00
|
|
|
%a = invoke {i64,i64} @test4a()
|
|
|
|
to label %A unwind label %B
|
|
|
|
A:
|
|
|
|
%b = extractvalue {i64,i64} %a, 0
|
|
|
|
%c = call i64 @test4c(i64 %b)
|
|
|
|
ret i64 %c
|
|
|
|
B:
|
2015-06-18 04:52:32 +08:00
|
|
|
%val = landingpad { i8*, i32 }
|
2011-09-01 04:55:40 +08:00
|
|
|
catch i8* null
|
2009-10-21 05:00:47 +08:00
|
|
|
ret i64 0
|
|
|
|
}
|
|
|
|
; CHECK: define i64 @test4b()
|
|
|
|
; CHECK: %c = call i64 @test4c(i64 5)
|
|
|
|
; CHECK-NEXT: ret i64 5
|
|
|
|
|
|
|
|
|
|
|
|
define internal i64 @test4c(i64 %a) {
|
|
|
|
ret i64 %a
|
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define internal i64 @test4c(
|
2009-10-21 05:00:47 +08:00
|
|
|
; CHECK: ret i64 undef
|
2009-10-21 05:04:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;======================== test5
|
|
|
|
|
|
|
|
; PR4313
|
|
|
|
define internal {i64,i64} @test5a() {
|
|
|
|
%a = insertvalue {i64,i64} undef, i64 4, 1
|
|
|
|
%b = insertvalue {i64,i64} %a, i64 5, 0
|
|
|
|
ret {i64,i64} %b
|
|
|
|
}
|
|
|
|
|
2015-06-18 04:52:32 +08:00
|
|
|
define i64 @test5b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2009-10-21 05:04:26 +08:00
|
|
|
%a = invoke {i64,i64} @test5a()
|
|
|
|
to label %A unwind label %B
|
|
|
|
A:
|
|
|
|
%c = call i64 @test5c({i64,i64} %a)
|
|
|
|
ret i64 %c
|
|
|
|
B:
|
2015-06-18 04:52:32 +08:00
|
|
|
%val = landingpad { i8*, i32 }
|
2011-09-01 04:55:40 +08:00
|
|
|
catch i8* null
|
2009-10-21 05:04:26 +08:00
|
|
|
ret i64 0
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: define i64 @test5b()
|
|
|
|
; CHECK: A:
|
2016-07-14 10:51:41 +08:00
|
|
|
; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } { i64 5, i64 4 })
|
2009-11-04 07:40:48 +08:00
|
|
|
; CHECK-NEXT: ret i64 5
|
2009-10-21 05:04:26 +08:00
|
|
|
|
|
|
|
define internal i64 @test5c({i64,i64} %a) {
|
|
|
|
%b = extractvalue {i64,i64} %a, 0
|
|
|
|
ret i64 %b
|
|
|
|
}
|
|
|
|
|
2009-11-02 15:33:59 +08:00
|
|
|
|
|
|
|
;;======================== test6
|
|
|
|
|
|
|
|
define i64 @test6a() {
|
|
|
|
ret i64 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test6b() {
|
|
|
|
%a = call i64 @test6a()
|
|
|
|
ret i64 %a
|
|
|
|
}
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i64 @test6b(
|
2009-11-02 15:33:59 +08:00
|
|
|
; CHECK: ret i64 0
|
|
|
|
|
2009-11-03 02:27:22 +08:00
|
|
|
;;======================== test7
|
|
|
|
|
|
|
|
|
|
|
|
%T = type {i32,i32}
|
|
|
|
|
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
llvm-svn: 134829
2011-07-10 01:41:24 +08:00
|
|
|
define internal %T @test7a(i32 %A) {
|
2009-11-03 02:27:22 +08:00
|
|
|
%X = add i32 1, %A
|
|
|
|
%mrv0 = insertvalue %T undef, i32 %X, 0
|
|
|
|
%mrv1 = insertvalue %T %mrv0, i32 %A, 1
|
|
|
|
ret %T %mrv1
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test7a(
|
2016-07-21 04:17:13 +08:00
|
|
|
; CHECK-NEXT: ret %T undef
|
2009-11-03 02:27:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test7b() {
|
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
llvm-svn: 134829
2011-07-10 01:41:24 +08:00
|
|
|
%X = call %T @test7a(i32 17)
|
|
|
|
%Y = extractvalue %T %X, 0
|
2009-11-03 02:27:22 +08:00
|
|
|
%Z = add i32 %Y, %Y
|
|
|
|
ret i32 %Z
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @test7b(
|
2009-11-03 02:27:22 +08:00
|
|
|
; CHECK-NEXT: call %T @test7a(i32 17)
|
|
|
|
; CHECK-NEXT: ret i32 36
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:24:51 +08:00
|
|
|
;;======================== test8
|
|
|
|
|
|
|
|
|
|
|
|
define internal {} @test8a(i32 %A, i32* %P) {
|
|
|
|
store i32 %A, i32* %P
|
|
|
|
ret {} {}
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test8a(
|
2009-11-04 03:24:51 +08:00
|
|
|
; CHECK-NEXT: store i32 5,
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test8b(i32* %P) {
|
|
|
|
%X = call {} @test8a(i32 5, i32* %P)
|
|
|
|
ret void
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test8b(
|
2010-04-09 02:03:05 +08:00
|
|
|
; CHECK-NEXT: call {} @test8a
|
2009-11-04 03:24:51 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
2009-11-04 05:25:50 +08:00
|
|
|
;;======================== test9
|
2009-11-04 03:24:51 +08:00
|
|
|
|
2009-11-04 05:25:50 +08:00
|
|
|
@test9g = internal global { } zeroinitializer
|
|
|
|
|
|
|
|
define void @test9() {
|
|
|
|
entry:
|
|
|
|
%local_foo = alloca { }
|
2015-02-28 05:17:42 +08:00
|
|
|
load { }, { }* @test9g
|
2009-11-04 05:25:50 +08:00
|
|
|
store { } %0, { }* %local_foo
|
|
|
|
ret void
|
|
|
|
}
|
2009-11-03 02:27:22 +08:00
|
|
|
|
2016-07-14 10:51:41 +08:00
|
|
|
; CHECK-LABEL: define void @test9(
|
|
|
|
; CHECK-NEXT: entry:
|
|
|
|
; CHECK-NEXT: %local_foo = alloca {}
|
|
|
|
; CHECK-NEXT: store {} zeroinitializer, {}* %local_foo
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
|
2011-09-01 04:55:40 +08:00
|
|
|
declare i32 @__gxx_personality_v0(...)
|
2011-09-21 07:28:51 +08:00
|
|
|
|
|
|
|
;;======================== test10
|
|
|
|
|
|
|
|
define i32 @test10a() nounwind {
|
|
|
|
entry:
|
|
|
|
%call = call i32 @test10b(i32 undef)
|
|
|
|
ret i32 %call
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @test10a(
|
2011-09-21 07:28:51 +08:00
|
|
|
; CHECK: ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define internal i32 @test10b(i32 %x) nounwind {
|
|
|
|
entry:
|
|
|
|
%r = and i32 %x, 1
|
|
|
|
ret i32 %r
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define internal i32 @test10b(
|
2011-09-21 07:28:51 +08:00
|
|
|
; CHECK: ret i32 undef
|
|
|
|
}
|
2014-11-07 16:54:19 +08:00
|
|
|
|
|
|
|
;;======================== test11
|
|
|
|
|
|
|
|
define i64 @test11a() {
|
|
|
|
%xor = xor i64 undef, undef
|
|
|
|
ret i64 %xor
|
|
|
|
; CHECK-LABEL: define i64 @test11a
|
|
|
|
; CHECK: ret i64 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test11b() {
|
|
|
|
%call1 = call i64 @test11a()
|
|
|
|
%call2 = call i64 @llvm.ctpop.i64(i64 %call1)
|
|
|
|
ret void
|
|
|
|
; CHECK-LABEL: define void @test11b
|
|
|
|
; CHECK: %[[call1:.*]] = call i64 @test11a()
|
|
|
|
; CHECK: %[[call2:.*]] = call i64 @llvm.ctpop.i64(i64 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i64 @llvm.ctpop.i64(i64)
|