summaryrefslogtreecommitdiffstats
path: root/test/Transforms/ConstProp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-02-20 12:57:14 +0000
committerdim <dim@FreeBSD.org>2011-02-20 12:57:14 +0000
commitcbb70ce070d220642b038ea101d9c0f9fbf860d6 (patch)
treed2b61ce94e654cb01a254d2195259db5f9cc3f3c /test/Transforms/ConstProp
parent4ace901e87dac5bbbac78ed325e75462e48e386e (diff)
downloadFreeBSD-src-cbb70ce070d220642b038ea101d9c0f9fbf860d6.zip
FreeBSD-src-cbb70ce070d220642b038ea101d9c0f9fbf860d6.tar.gz
Vendor import of llvm trunk r126079:
http://llvm.org/svn/llvm-project/llvm/trunk@126079
Diffstat (limited to 'test/Transforms/ConstProp')
-rw-r--r--test/Transforms/ConstProp/basictest.ll9
-rw-r--r--test/Transforms/ConstProp/bitcast.ll12
-rw-r--r--test/Transforms/ConstProp/bitcast2.ll8
-rw-r--r--test/Transforms/ConstProp/calls.ll58
-rw-r--r--test/Transforms/ConstProp/constant-expr.ll44
-rw-r--r--test/Transforms/ConstProp/extractvalue.ll68
-rw-r--r--test/Transforms/ConstProp/insertvalue.ll68
-rw-r--r--test/Transforms/ConstProp/loads.ll17
-rw-r--r--test/Transforms/ConstProp/logicaltest.ll4
-rw-r--r--test/Transforms/ConstProp/nottest.ll19
-rw-r--r--test/Transforms/ConstProp/overflow-ops.ll11
11 files changed, 271 insertions, 47 deletions
diff --git a/test/Transforms/ConstProp/basictest.ll b/test/Transforms/ConstProp/basictest.ll
index 14580c1..df57fb6 100644
--- a/test/Transforms/ConstProp/basictest.ll
+++ b/test/Transforms/ConstProp/basictest.ll
@@ -31,3 +31,12 @@ bb:
; CHECK: @test2
; CHECK: ret i1 true
}
+
+define i1 @TNAN() {
+; CHECK: @TNAN
+; CHECK: ret i1 true
+ %A = fcmp uno double 0x7FF8000000000000, 1.000000e+00
+ %B = fcmp uno double 1.230000e+02, 1.000000e+00
+ %C = or i1 %A, %B
+ ret i1 %C
+}
diff --git a/test/Transforms/ConstProp/bitcast.ll b/test/Transforms/ConstProp/bitcast.ll
index bf943c9..53239c7 100644
--- a/test/Transforms/ConstProp/bitcast.ll
+++ b/test/Transforms/ConstProp/bitcast.ll
@@ -1,2 +1,10 @@
-; RUN: llvm-as < %s | llvm-dis | grep 0x36A0000000000000
-@A = global float 0x36A0000000000000 ; <float*> [#uses=0]
+; RUN: opt < %s -constprop -S | FileCheck %s
+; PR2165
+
+define <1 x i64> @test1() {
+ %A = bitcast i64 63 to <1 x i64>
+ ret <1 x i64> %A
+; CHECK: @test1
+; CHECK: ret <1 x i64> <i64 63>
+}
+
diff --git a/test/Transforms/ConstProp/bitcast2.ll b/test/Transforms/ConstProp/bitcast2.ll
deleted file mode 100644
index 5c5eab1..0000000
--- a/test/Transforms/ConstProp/bitcast2.ll
+++ /dev/null
@@ -1,8 +0,0 @@
-; RUN: opt < %s -instcombine -S | not grep bitcast
-; PR2165
-
-define <1 x i64> @test() {
- %A = bitcast i64 63 to <1 x i64>
- ret <1 x i64> %A
-}
-
diff --git a/test/Transforms/ConstProp/calls.ll b/test/Transforms/ConstProp/calls.ll
index 3c266fe..82d7324 100644
--- a/test/Transforms/ConstProp/calls.ll
+++ b/test/Transforms/ConstProp/calls.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -constprop -S | not grep call
+; RUN: opt < %s -constprop -S | FileCheck %s
declare double @cos(double)
@@ -8,23 +8,49 @@ declare double @tan(double)
declare double @sqrt(double)
-declare i1 @llvm.isunordered.f64(double, double)
-
define double @T() {
- %A = call double @cos( double 0.000000e+00 ) ; <double> [#uses=1]
- %B = call double @sin( double 0.000000e+00 ) ; <double> [#uses=1]
- %a = fadd double %A, %B ; <double> [#uses=1]
- %C = call double @tan( double 0.000000e+00 ) ; <double> [#uses=1]
- %b = fadd double %a, %C ; <double> [#uses=1]
- %D = call double @sqrt( double 4.000000e+00 ) ; <double> [#uses=1]
- %c = fadd double %b, %D ; <double> [#uses=1]
- ret double %c
+; CHECK: @T
+; CHECK-NOT: call
+; CHECK: ret
+ %A = call double @cos(double 0.000000e+00)
+ %B = call double @sin(double 0.000000e+00)
+ %a = fadd double %A, %B
+ %C = call double @tan(double 0.000000e+00)
+ %b = fadd double %a, %C
+ %D = call double @sqrt(double 4.000000e+00)
+ %c = fadd double %b, %D
+ ret double %c
}
-define i1 @TNAN() {
- %A = fcmp uno double 0x7FF8000000000000, 1.000000e+00 ; <i1> [#uses=1]
- %B = fcmp uno double 1.230000e+02, 1.000000e+00 ; <i1> [#uses=1]
- %C = or i1 %A, %B ; <i1> [#uses=1]
- ret i1 %C
+define i1 @test_sse_cvt() nounwind readnone {
+; CHECK: @test_sse_cvt
+; CHECK-NOT: call
+; CHECK: ret i1 true
+entry:
+ %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
+ %i1 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
+ %i2 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
+ %i3 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
+ %i4 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> <double 1.75, double undef>) nounwind
+ %i5 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> <double 1.75, double undef>) nounwind
+ %i6 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> <double 1.75, double undef>) nounwind
+ %i7 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> <double 1.75, double undef>) nounwind
+ %sum11 = add i32 %i0, %i1
+ %sum12 = add i32 %i4, %i5
+ %sum1 = add i32 %sum11, %sum12
+ %sum21 = add i64 %i2, %i3
+ %sum22 = add i64 %i6, %i7
+ %sum2 = add i64 %sum21, %sum22
+ %sum1.sext = sext i32 %sum1 to i64
+ %b = icmp eq i64 %sum1.sext, %sum2
+ ret i1 %b
}
+declare i32 @llvm.x86.sse.cvtss2si(<4 x float>) nounwind readnone
+declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) nounwind readnone
+declare i64 @llvm.x86.sse.cvtss2si64(<4 x float>) nounwind readnone
+declare i64 @llvm.x86.sse.cvttss2si64(<4 x float>) nounwind readnone
+declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone
+declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone
+declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone
+declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone
diff --git a/test/Transforms/ConstProp/constant-expr.ll b/test/Transforms/ConstProp/constant-expr.ll
index 556ed1f..1088fa6 100644
--- a/test/Transforms/ConstProp/constant-expr.ll
+++ b/test/Transforms/ConstProp/constant-expr.ll
@@ -65,3 +65,47 @@
; No check line. This used to crash llvm-as.
@T6 = global <2 x i1> fcmp ole (<2 x float> fdiv (<2 x float> undef, <2 x float> <float 1.000000e+00, float 1.000000e+00>), <2 x float> zeroinitializer)
+
+
+; PR9011
+
+@pr9011_1 = constant <4 x i32> zext (<4 x i8> zeroinitializer to <4 x i32>)
+; CHECK: pr9011_1 = constant <4 x i32> zeroinitializer
+@pr9011_2 = constant <4 x i32> sext (<4 x i8> zeroinitializer to <4 x i32>)
+; CHECK: pr9011_2 = constant <4 x i32> zeroinitializer
+@pr9011_3 = constant <4 x i32> bitcast (<16 x i8> zeroinitializer to <4 x i32>)
+; CHECK: pr9011_3 = constant <4 x i32> zeroinitializer
+@pr9011_4 = constant <4 x float> uitofp (<4 x i8> zeroinitializer to <4 x float>)
+; CHECK: pr9011_4 = constant <4 x float> zeroinitializer
+@pr9011_5 = constant <4 x float> sitofp (<4 x i8> zeroinitializer to <4 x float>)
+; CHECK: pr9011_5 = constant <4 x float> zeroinitializer
+@pr9011_6 = constant <4 x i32> fptosi (<4 x float> zeroinitializer to <4 x i32>)
+; CHECK: pr9011_6 = constant <4 x i32> zeroinitializer
+@pr9011_7 = constant <4 x i32> fptoui (<4 x float> zeroinitializer to <4 x i32>)
+; CHECK: pr9011_7 = constant <4 x i32> zeroinitializer
+@pr9011_8 = constant <4 x float> fptrunc (<4 x double> zeroinitializer to <4 x float>)
+; CHECK: pr9011_8 = constant <4 x float> zeroinitializer
+@pr9011_9 = constant <4 x double> fpext (<4 x float> zeroinitializer to <4 x double>)
+; CHECK: pr9011_9 = constant <4 x double> zeroinitializer
+
+@pr9011_10 = constant <4 x double> bitcast (i256 0 to <4 x double>)
+; CHECK: pr9011_10 = constant <4 x double> zeroinitializer
+@pr9011_11 = constant <4 x float> bitcast (i128 0 to <4 x float>)
+; CHECK: pr9011_11 = constant <4 x float> zeroinitializer
+@pr9011_12 = constant <4 x i32> bitcast (i128 0 to <4 x i32>)
+; CHECK: pr9011_12 = constant <4 x i32> zeroinitializer
+@pr9011_13 = constant i256 bitcast (<4 x double> zeroinitializer to i256)
+; CHECK: pr9011_13 = constant i256 0
+@pr9011_14 = constant i128 bitcast (<4 x float> zeroinitializer to i128)
+; CHECK: pr9011_14 = constant i128 0
+@pr9011_15 = constant i128 bitcast (<4 x i32> zeroinitializer to i128)
+; CHECK: pr9011_15 = constant i128 0
+
+@select = internal constant
+ i32 select (i1 icmp ult (i32 ptrtoint (i8* @X to i32),
+ i32 ptrtoint (i8* @Y to i32)),
+ i32 select (i1 icmp ult (i32 ptrtoint (i8* @X to i32),
+ i32 ptrtoint (i8* @Y to i32)),
+ i32 10, i32 20),
+ i32 30)
+; CHECK: select = internal constant i32 select {{.*}} i32 10, i32 30
diff --git a/test/Transforms/ConstProp/extractvalue.ll b/test/Transforms/ConstProp/extractvalue.ll
new file mode 100644
index 0000000..32d5291
--- /dev/null
+++ b/test/Transforms/ConstProp/extractvalue.ll
@@ -0,0 +1,68 @@
+; RUN: opt < %s -constprop -S | FileCheck %s
+
+%struct = type { i32, [4 x i8] }
+%array = type [3 x %struct]
+
+define i32 @test1() {
+ %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 0
+ ret i32 %A
+; CHECK: @test1
+; CHECK: ret i32 2
+}
+
+define i8 @test2() {
+ %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 1, 2
+ ret i8 %A
+; CHECK: @test2
+; CHECK: ret i8 111
+}
+
+define i32 @test3() {
+ %A = extractvalue %array [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], 1, 0
+ ret i32 %A
+; CHECK: @test3
+; CHECK: ret i32 1
+}
+
+define i32 @zeroinitializer-test1() {
+ %A = extractvalue %struct zeroinitializer, 0
+ ret i32 %A
+; CHECK: @zeroinitializer-test1
+; CHECK: ret i32 0
+}
+
+define i8 @zeroinitializer-test2() {
+ %A = extractvalue %struct zeroinitializer, 1, 2
+ ret i8 %A
+; CHECK: @zeroinitializer-test2
+; CHECK: ret i8 0
+}
+
+define i32 @zeroinitializer-test3() {
+ %A = extractvalue %array zeroinitializer, 1, 0
+ ret i32 %A
+; CHECK: @zeroinitializer-test3
+; CHECK: ret i32 0
+}
+
+define i32 @undef-test1() {
+ %A = extractvalue %struct undef, 0
+ ret i32 %A
+; CHECK: @undef-test1
+; CHECK: ret i32 undef
+}
+
+define i8 @undef-test2() {
+ %A = extractvalue %struct undef, 1, 2
+ ret i8 %A
+; CHECK: @undef-test2
+; CHECK: ret i8 undef
+}
+
+define i32 @undef-test3() {
+ %A = extractvalue %array undef, 1, 0
+ ret i32 %A
+; CHECK: @undef-test3
+; CHECK: ret i32 undef
+}
+
diff --git a/test/Transforms/ConstProp/insertvalue.ll b/test/Transforms/ConstProp/insertvalue.ll
new file mode 100644
index 0000000..f0eb553
--- /dev/null
+++ b/test/Transforms/ConstProp/insertvalue.ll
@@ -0,0 +1,68 @@
+; RUN: opt < %s -constprop -S | FileCheck %s
+
+%struct = type { i32, [4 x i8] }
+%array = type [3 x %struct]
+
+define %struct @test1() {
+ %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i32 1, 0
+ ret %struct %A
+; CHECK: @test1
+; CHECK: ret %struct { i32 1, [4 x i8] c"foo\00" }
+}
+
+define %struct @test2() {
+ %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i8 1, 1, 2
+ ret %struct %A
+; CHECK: @test2
+; CHECK: ret %struct { i32 2, [4 x i8] c"fo\01\00" }
+}
+
+define %array @test3() {
+ %A = insertvalue %array [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], i32 -1, 1, 0
+ ret %array %A
+; CHECK: @test3
+; CHECK:ret %array [%struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 -1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" }]
+}
+
+define %struct @zeroinitializer-test1() {
+ %A = insertvalue %struct zeroinitializer, i32 1, 0
+ ret %struct %A
+; CHECK: @zeroinitializer-test1
+; CHECK: ret %struct { i32 1, [4 x i8] zeroinitializer }
+}
+
+define %struct @zeroinitializer-test2() {
+ %A = insertvalue %struct zeroinitializer, i8 1, 1, 2
+ ret %struct %A
+; CHECK: @zeroinitializer-test2
+; CHECK: ret %struct { i32 0, [4 x i8] c"\00\00\01\00" }
+}
+
+define %array @zeroinitializer-test3() {
+ %A = insertvalue %array zeroinitializer, i32 1, 1, 0
+ ret %array %A
+; CHECK: @zeroinitializer-test3
+; CHECK: ret %array [%struct zeroinitializer, %struct { i32 1, [4 x i8] zeroinitializer }, %struct zeroinitializer]
+}
+
+define %struct @undef-test1() {
+ %A = insertvalue %struct undef, i32 1, 0
+ ret %struct %A
+; CHECK: @undef-test1
+; CHECK: ret %struct { i32 1, [4 x i8] undef }
+}
+
+define %struct @undef-test2() {
+ %A = insertvalue %struct undef, i8 0, 1, 2
+ ret %struct %A
+; CHECK: @undef-test2
+; CHECK: ret %struct { i32 undef, [4 x i8] [i8 undef, i8 undef, i8 0, i8 undef] }
+}
+
+define %array @undef-test3() {
+ %A = insertvalue %array undef, i32 0, 1, 0
+ ret %array %A
+; CHECK: @undef-test3
+; CHECK: ret %array [%struct undef, %struct { i32 0, [4 x i8] undef }, %struct undef]
+}
+
diff --git a/test/Transforms/ConstProp/loads.ll b/test/Transforms/ConstProp/loads.ll
index 9fbba2b..74d80aa 100644
--- a/test/Transforms/ConstProp/loads.ll
+++ b/test/Transforms/ConstProp/loads.ll
@@ -120,3 +120,20 @@ define i1 @test13() {
; CHECK: @test13
; CHECK: ret i1 false
}
+
+@g6 = constant [2 x i8*] [i8* inttoptr (i64 1 to i8*), i8* inttoptr (i64 2 to i8*)]
+define i64 @test14() nounwind {
+entry:
+ %tmp = load i64* bitcast ([2 x i8*]* @g6 to i64*)
+ ret i64 %tmp
+; CHECK: @test14
+; CHECK: ret i64 1
+}
+
+define i64 @test15() nounwind {
+entry:
+ %tmp = load i64* bitcast (i8** getelementptr inbounds ([2 x i8*]* @g6, i32 0, i64 1) to i64*)
+ ret i64 %tmp
+; CHECK: @test15
+; CHECK: ret i64 2
+}
diff --git a/test/Transforms/ConstProp/logicaltest.ll b/test/Transforms/ConstProp/logicaltest.ll
index 7a90a71..c74296a 100644
--- a/test/Transforms/ConstProp/logicaltest.ll
+++ b/test/Transforms/ConstProp/logicaltest.ll
@@ -1,7 +1,7 @@
; Ensure constant propogation of logical instructions is working correctly.
-; RUN: opt < %s -constprop -die -S | \
-; RUN: not egrep {and|or|xor}
+; RUN: opt < %s -constprop -die -S | FileCheck %s
+; CHECK-NOT: {{and|or|xor}}
define i32 @test1() {
%R = and i32 4, 1234 ; <i32> [#uses=1]
diff --git a/test/Transforms/ConstProp/nottest.ll b/test/Transforms/ConstProp/nottest.ll
deleted file mode 100644
index 799ceca..0000000
--- a/test/Transforms/ConstProp/nottest.ll
+++ /dev/null
@@ -1,19 +0,0 @@
-; Ensure constant propogation of 'not' instructions is working correctly.
-
-; RUN: opt < %s -constprop -die -S | not grep xor
-
-define i32 @test1() {
- %R = xor i32 4, -1 ; <i32> [#uses=1]
- ret i32 %R
-}
-
-define i32 @test2() {
- %R = xor i32 -23, -1 ; <i32> [#uses=1]
- ret i32 %R
-}
-
-define i1 @test3() {
- %R = xor i1 true, true ; <i1> [#uses=1]
- ret i1 %R
-}
-
diff --git a/test/Transforms/ConstProp/overflow-ops.ll b/test/Transforms/ConstProp/overflow-ops.ll
index 1547a4d..5587e9b 100644
--- a/test/Transforms/ConstProp/overflow-ops.ll
+++ b/test/Transforms/ConstProp/overflow-ops.ll
@@ -170,3 +170,14 @@ declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8)
declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8)
declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8)
+declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8)
+
+; rdar://8501501
+define {i8, i1} @smul_1() nounwind {
+entry:
+ %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10)
+ ret {i8, i1} %t
+
+; CHECK: @smul_1
+; CHECK: ret %i8i1 { i8 -56, i1 true }
+}
OpenPOWER on IntegriCloud