summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/bswap-fold.ll10
-rw-r--r--test/Transforms/InstCombine/call.ll11
-rw-r--r--test/Transforms/InstCombine/extractelement.ll12
-rw-r--r--test/Transforms/InstCombine/fmul-sqrt.ll67
-rw-r--r--test/Transforms/InstCombine/intrinsics.ll8
-rw-r--r--test/Transforms/InstCombine/udiv-simplify.ll39
-rw-r--r--test/Transforms/InstCombine/vec_demanded_elts.ll6
-rw-r--r--test/Transforms/InstCombine/vector_insertelt_shuffle.ll4
-rw-r--r--test/Transforms/InstSimplify/bitreverse-fold.ll (renamed from test/Transforms/InstCombine/bitreverse-fold.ll)2
-rw-r--r--test/Transforms/InstSimplify/exp-intrinsic.ll71
-rw-r--r--test/Transforms/InstSimplify/exp2-intrinsic.ll71
-rw-r--r--test/Transforms/InstSimplify/extract-element.ll38
-rw-r--r--test/Transforms/InstSimplify/fold-intrinsics.ll27
-rw-r--r--test/Transforms/InstSimplify/insertelement.ll6
-rw-r--r--test/Transforms/InstSimplify/log-intrinsic.ll71
-rw-r--r--test/Transforms/InstSimplify/log2-intrinsic.ll71
-rw-r--r--test/Transforms/LoopRotate/pr35210.ll4
-rw-r--r--test/Transforms/LoopSimplify/unreachable-loop-pred.ll49
-rw-r--r--test/Transforms/SimplifyCFG/pr35774.ll35
19 files changed, 564 insertions, 38 deletions
diff --git a/test/Transforms/InstCombine/bswap-fold.ll b/test/Transforms/InstCombine/bswap-fold.ll
index 260e2330996ed..8fdecb628b858 100644
--- a/test/Transforms/InstCombine/bswap-fold.ll
+++ b/test/Transforms/InstCombine/bswap-fold.ll
@@ -13,16 +13,6 @@ define i32 @test4(i32 %a) nounwind {
ret i32 %tmp4
}
-; A
-define i32 @test5(i32 %a) nounwind {
-; CHECK-LABEL: @test5(
-; CHECK-NEXT: ret i32 %a
-;
- %tmp2 = tail call i32 @llvm.bswap.i32( i32 %a )
- %tmp4 = tail call i32 @llvm.bswap.i32( i32 %tmp2 )
- ret i32 %tmp4
-}
-
; a >> 24
define i32 @test6(i32 %a) nounwind {
; CHECK-LABEL: @test6(
diff --git a/test/Transforms/InstCombine/call.ll b/test/Transforms/InstCombine/call.ll
index 5307dcb6df721..c494bfb62c79b 100644
--- a/test/Transforms/InstCombine/call.ll
+++ b/test/Transforms/InstCombine/call.ll
@@ -287,3 +287,14 @@ entry:
; CHECK-LABEL: @test17(
; CHECK: call i32 @pr28655(i32 0)
; CHECK: ret i32 0
+
+define void @non_vararg(i8*, i32) {
+ ret void
+}
+
+define void @test_cast_to_vararg(i8* %this) {
+; CHECK-LABEL: test_cast_to_vararg
+; CHECK: call void @non_vararg(i8* %this, i32 42)
+ call void (i8*, ...) bitcast (void (i8*, i32)* @non_vararg to void (i8*, ...)*)(i8* %this, i32 42)
+ ret void
+}
diff --git a/test/Transforms/InstCombine/extractelement.ll b/test/Transforms/InstCombine/extractelement.ll
index 66fbd25947dc1..f4043335c4e46 100644
--- a/test/Transforms/InstCombine/extractelement.ll
+++ b/test/Transforms/InstCombine/extractelement.ll
@@ -3,9 +3,17 @@
define i32 @extractelement_out_of_range(<2 x i32> %x) {
; CHECK-LABEL: @extractelement_out_of_range(
-; CHECK-NEXT: [[E1:%.*]] = extractelement <2 x i32> [[X:%.*]], i8 16
-; CHECK-NEXT: ret i32 [[E1]]
+; CHECK-NEXT: ret i32 undef
;
%E1 = extractelement <2 x i32> %x, i8 16
ret i32 %E1
}
+
+define i32 @extractelement_type_out_of_range(<2 x i32> %x) {
+; CHECK-LABEL: @extractelement_type_out_of_range(
+; CHECK-NEXT: [[E1:%.*]] = extractelement <2 x i32> [[X:%.*]], i128 0
+; CHECK-NEXT: ret i32 [[E1]]
+;
+ %E1 = extractelement <2 x i32> %x, i128 0
+ ret i32 %E1
+}
diff --git a/test/Transforms/InstCombine/fmul-sqrt.ll b/test/Transforms/InstCombine/fmul-sqrt.ll
new file mode 100644
index 0000000000000..0031a61059ab2
--- /dev/null
+++ b/test/Transforms/InstCombine/fmul-sqrt.ll
@@ -0,0 +1,67 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+declare double @llvm.sqrt.f64(double) nounwind readnone speculatable
+declare void @use(double)
+
+; sqrt(a) * sqrt(b) no math flags
+define double @sqrt_a_sqrt_b(double %a, double %b) {
+; CHECK-LABEL: @sqrt_a_sqrt_b(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.sqrt.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.sqrt.f64(double [[B:%.*]])
+; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret double [[MUL]]
+;
+ %1 = call double @llvm.sqrt.f64(double %a)
+ %2 = call double @llvm.sqrt.f64(double %b)
+ %mul = fmul double %1, %2
+ ret double %mul
+}
+
+; sqrt(a) * sqrt(b) fast-math, multiple uses
+define double @sqrt_a_sqrt_b_multiple_uses(double %a, double %b) {
+; CHECK-LABEL: @sqrt_a_sqrt_b_multiple_uses(
+; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.sqrt.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call fast double @llvm.sqrt.f64(double [[B:%.*]])
+; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[TMP1]], [[TMP2]]
+; CHECK-NEXT: call void @use(double [[TMP2]])
+; CHECK-NEXT: ret double [[MUL]]
+;
+ %1 = call fast double @llvm.sqrt.f64(double %a)
+ %2 = call fast double @llvm.sqrt.f64(double %b)
+ %mul = fmul fast double %1, %2
+ call void @use(double %2)
+ ret double %mul
+}
+
+; sqrt(a) * sqrt(b) => sqrt(a*b) with fast-math
+define double @sqrt_a_sqrt_b_fast(double %a, double %b) {
+; CHECK-LABEL: @sqrt_a_sqrt_b_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = call fast double @llvm.sqrt.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call fast double @llvm.sqrt.f64(double %a)
+ %2 = call fast double @llvm.sqrt.f64(double %b)
+ %mul = fmul fast double %1, %2
+ ret double %mul
+}
+
+; sqrt(a) * sqrt(b) * sqrt(c) * sqrt(d) => sqrt(a*b*c+d) with fast-math
+define double @sqrt_a_sqrt_b_sqrt_c_sqrt_d_fast(double %a, double %b, double %c, double %d) {
+; CHECK-LABEL: @sqrt_a_sqrt_b_sqrt_c_sqrt_d_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[C:%.*]]
+; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[D:%.*]]
+; CHECK-NEXT: [[TMP4:%.*]] = call fast double @llvm.sqrt.f64(double [[TMP3]])
+; CHECK-NEXT: ret double [[TMP4]]
+;
+ %1 = call fast double @llvm.sqrt.f64(double %a)
+ %2 = call fast double @llvm.sqrt.f64(double %b)
+ %mul = fmul fast double %1, %2
+ %3 = call fast double @llvm.sqrt.f64(double %c)
+ %mul1 = fmul fast double %mul, %3
+ %4 = call fast double @llvm.sqrt.f64(double %d)
+ %mul2 = fmul fast double %mul1, %4
+ ret double %mul2
+}
diff --git a/test/Transforms/InstCombine/intrinsics.ll b/test/Transforms/InstCombine/intrinsics.ll
index e0698f8b3b77e..73f1cd9201641 100644
--- a/test/Transforms/InstCombine/intrinsics.ll
+++ b/test/Transforms/InstCombine/intrinsics.ll
@@ -262,20 +262,12 @@ define void @powi(double %V, double *%P) {
%A = tail call double @llvm.powi.f64(double %V, i32 -1) nounwind
store volatile double %A, double* %P
- %B = tail call double @llvm.powi.f64(double %V, i32 0) nounwind
- store volatile double %B, double* %P
-
- %C = tail call double @llvm.powi.f64(double %V, i32 1) nounwind
- store volatile double %C, double* %P
-
%D = tail call double @llvm.powi.f64(double %V, i32 2) nounwind
store volatile double %D, double* %P
ret void
; CHECK-LABEL: @powi(
; CHECK: %A = fdiv double 1.0{{.*}}, %V
; CHECK: store volatile double %A,
-; CHECK: store volatile double 1.0
-; CHECK: store volatile double %V
; CHECK: %D = fmul double %V, %V
; CHECK: store volatile double %D
}
diff --git a/test/Transforms/InstCombine/udiv-simplify.ll b/test/Transforms/InstCombine/udiv-simplify.ll
index 6f43fee92a6a5..1794e26d389d6 100644
--- a/test/Transforms/InstCombine/udiv-simplify.ll
+++ b/test/Transforms/InstCombine/udiv-simplify.ll
@@ -25,10 +25,10 @@ define i64 @test2(i32 %x) nounwind {
define i64 @test1_PR2274(i32 %x, i32 %g) nounwind {
; CHECK-LABEL: @test1_PR2274(
-; CHECK-NEXT: [[Y:%.*]] = lshr i32 %x, 30
-; CHECK-NEXT: [[R:%.*]] = udiv i32 [[Y]], %g
-; CHECK-NEXT: [[Z1:%.*]] = zext i32 [[R]] to i64
-; CHECK-NEXT: ret i64 [[Z1]]
+; CHECK-NEXT: [[Y:%.*]] = lshr i32 [[X:%.*]], 30
+; CHECK-NEXT: [[R:%.*]] = udiv i32 [[Y]], [[G:%.*]]
+; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[R]] to i64
+; CHECK-NEXT: ret i64 [[TMP1]]
;
%y = lshr i32 %x, 30
%r = udiv i32 %y, %g
@@ -37,10 +37,10 @@ define i64 @test1_PR2274(i32 %x, i32 %g) nounwind {
}
define i64 @test2_PR2274(i32 %x, i32 %v) nounwind {
; CHECK-LABEL: @test2_PR2274(
-; CHECK-NEXT: [[Y:%.*]] = lshr i32 %x, 31
-; CHECK-NEXT: [[R:%.*]] = udiv i32 [[Y]], %v
-; CHECK-NEXT: [[Z1:%.*]] = zext i32 [[R]] to i64
-; CHECK-NEXT: ret i64 [[Z1]]
+; CHECK-NEXT: [[Y:%.*]] = lshr i32 [[X:%.*]], 31
+; CHECK-NEXT: [[R:%.*]] = udiv i32 [[Y]], [[V:%.*]]
+; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[R]] to i64
+; CHECK-NEXT: ret i64 [[TMP1]]
;
%y = lshr i32 %x, 31
%r = udiv i32 %y, %v
@@ -54,7 +54,7 @@ define i64 @test2_PR2274(i32 %x, i32 %v) nounwind {
define i32 @PR30366(i1 %a) {
; CHECK-LABEL: @PR30366(
-; CHECK-NEXT: [[Z:%.*]] = zext i1 %a to i32
+; CHECK-NEXT: [[Z:%.*]] = zext i1 [[A:%.*]] to i32
; CHECK-NEXT: [[D:%.*]] = lshr i32 [[Z]], zext (i16 ptrtoint ([1 x i16]* @b to i16) to i32)
; CHECK-NEXT: ret i32 [[D]]
;
@@ -62,3 +62,24 @@ define i32 @PR30366(i1 %a) {
%d = udiv i32 %z, zext (i16 shl (i16 1, i16 ptrtoint ([1 x i16]* @b to i16)) to i32)
ret i32 %d
}
+
+; OSS-Fuzz #4857
+; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4857
+define i177 @ossfuzz_4857(i177 %X, i177 %Y) {
+; CHECK-LABEL: @ossfuzz_4857(
+; CHECK-NEXT: store i1 false, i1* undef, align 1
+; CHECK-NEXT: ret i177 0
+;
+ %B5 = udiv i177 %Y, -1
+ %B4 = add i177 %B5, -1
+ %B2 = add i177 %B4, -1
+ %B6 = mul i177 %B5, %B2
+ %B3 = add i177 %B2, %B2
+ %B9 = xor i177 %B4, %B3
+ %B13 = ashr i177 %Y, %B2
+ %B22 = add i177 %B9, %B13
+ %B1 = udiv i177 %B5, %B6
+ %C9 = icmp ult i177 %Y, %B22
+ store i1 %C9, i1* undef
+ ret i177 %B1
+}
diff --git a/test/Transforms/InstCombine/vec_demanded_elts.ll b/test/Transforms/InstCombine/vec_demanded_elts.ll
index 9d59efbad7383..318df6cf76c1d 100644
--- a/test/Transforms/InstCombine/vec_demanded_elts.ll
+++ b/test/Transforms/InstCombine/vec_demanded_elts.ll
@@ -191,11 +191,11 @@ define <4 x i32> @inselt_shuf_no_demand_multiuse(i32 %a0, i32 %a1, <4 x i32> %b)
define <4 x float> @inselt_shuf_no_demand_bogus_insert_index_in_chain(float %a1, float %a2, float %a3, i32 %variable_index) {
; CHECK-LABEL: @inselt_shuf_no_demand_bogus_insert_index_in_chain(
-; CHECK-NEXT: [[OUT1:%.*]] = insertelement <4 x float> undef, float %a1, i32 1
-; CHECK-NEXT: ret <4 x float> [[OUT1]]
+; CHECK-NEXT: [[OUT12:%.*]] = insertelement <4 x float> undef, float [[A2:%.*]], i32 [[VARIABLE_INDEX:%.*]]
+; CHECK-NEXT: ret <4 x float> [[OUT12]]
;
%out1 = insertelement <4 x float> undef, float %a1, i32 1
- %out12 = insertelement <4 x float> %out1, float %a2, i32 undef ; something unexpected
+ %out12 = insertelement <4 x float> %out1, float %a2, i32 %variable_index ; something unexpected
%out123 = insertelement <4 x float> %out12, float %a3, i32 3
%shuffle = shufflevector <4 x float> %out123, <4 x float> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
ret <4 x float> %shuffle
diff --git a/test/Transforms/InstCombine/vector_insertelt_shuffle.ll b/test/Transforms/InstCombine/vector_insertelt_shuffle.ll
index 41c6370e48e9a..e5da608631937 100644
--- a/test/Transforms/InstCombine/vector_insertelt_shuffle.ll
+++ b/test/Transforms/InstCombine/vector_insertelt_shuffle.ll
@@ -66,9 +66,7 @@ define <4 x float> @bazzz(<4 x float> %x) {
define <4 x float> @bazzzz(<4 x float> %x) {
; CHECK-LABEL: @bazzzz(
-; CHECK-NEXT: [[INS1:%.*]] = insertelement <4 x float> %x, float 1.000000e+00, i32 undef
-; CHECK-NEXT: [[INS2:%.*]] = insertelement <4 x float> %x, float 2.000000e+00, i32 2
-; CHECK-NEXT: ret <4 x float> [[INS2]]
+; CHECK-NEXT: ret <4 x float> <float undef, float undef, float 2.000000e+00, float undef>
;
%ins1 = insertelement<4 x float> %x, float 1.0, i32 undef
%ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2
diff --git a/test/Transforms/InstCombine/bitreverse-fold.ll b/test/Transforms/InstSimplify/bitreverse-fold.ll
index b798ad33b3f08..eab4b07a16e94 100644
--- a/test/Transforms/InstCombine/bitreverse-fold.ll
+++ b/test/Transforms/InstSimplify/bitreverse-fold.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt < %s -instsimplify -S | FileCheck %s
define i32 @identity_bitreverse_i32(i32 %p) {
; CHECK-LABEL: @identity_bitreverse_i32(
diff --git a/test/Transforms/InstSimplify/exp-intrinsic.ll b/test/Transforms/InstSimplify/exp-intrinsic.ll
new file mode 100644
index 0000000000000..0fbd7e1a5e9c5
--- /dev/null
+++ b/test/Transforms/InstSimplify/exp-intrinsic.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare double @llvm.exp.f64(double)
+declare double @llvm.log.f64(double)
+
+define double @exp_log(double %a) {
+; CHECK-LABEL: @exp_log(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call double @llvm.log.f64(double %a)
+ %2 = call double @llvm.exp.f64(double %1)
+ ret double %2
+}
+
+define double @exp_log_fast(double %a) {
+; CHECK-LABEL: @exp_log_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.log.f64(double %a)
+ %2 = call fast double @llvm.exp.f64(double %1)
+ ret double %2
+}
+
+define double @exp_fast_log_strict(double %a) {
+; CHECK-LABEL: @exp_fast_log_strict(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call double @llvm.log.f64(double %a)
+ %2 = call fast double @llvm.exp.f64(double %1)
+ ret double %2
+}
+
+define double @exp_strict_log_fast(double %a) {
+; CHECK-LABEL: @exp_strict_log_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.log.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call fast double @llvm.log.f64(double %a)
+ %2 = call double @llvm.exp.f64(double %1)
+ ret double %2
+}
+
+define double @exp_log_exp_log(double %a) {
+; CHECK-LABEL: @exp_log_exp_log(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp.f64(double [[TMP1]])
+; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.log.f64(double [[TMP2]])
+; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.exp.f64(double [[TMP3]])
+; CHECK-NEXT: ret double [[TMP4]]
+;
+ %1 = call double @llvm.log.f64(double %a)
+ %2 = call double @llvm.exp.f64(double %1)
+ %3 = call double @llvm.log.f64(double %2)
+ %4 = call double @llvm.exp.f64(double %3)
+ ret double %4
+}
+
+define double @exp_log_exp_log_fast(double %a) {
+; CHECK-LABEL: @exp_log_exp_log_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.log.f64(double %a)
+ %2 = call fast double @llvm.exp.f64(double %1)
+ %3 = call fast double @llvm.log.f64(double %2)
+ %4 = call fast double @llvm.exp.f64(double %3)
+ ret double %4
+}
diff --git a/test/Transforms/InstSimplify/exp2-intrinsic.ll b/test/Transforms/InstSimplify/exp2-intrinsic.ll
new file mode 100644
index 0000000000000..6b93b14b7118c
--- /dev/null
+++ b/test/Transforms/InstSimplify/exp2-intrinsic.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare double @llvm.exp2.f64(double)
+declare double @llvm.log2.f64(double)
+
+define double @exp2_log2(double %a) {
+; CHECK-LABEL: @exp2_log2(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log2.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp2.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call double @llvm.log2.f64(double %a)
+ %2 = call double @llvm.exp2.f64(double %1)
+ ret double %2
+}
+
+define double @exp2_log2_fast(double %a) {
+; CHECK-LABEL: @exp2_log2_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.log2.f64(double %a)
+ %2 = call fast double @llvm.exp2.f64(double %1)
+ ret double %2
+}
+
+define double @exp2_fast_log2_strict(double %a) {
+; CHECK-LABEL: @exp2_fast_log2_strict(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call double @llvm.log2.f64(double %a)
+ %2 = call fast double @llvm.exp2.f64(double %1)
+ ret double %2
+}
+
+define double @exp2_strict_log2_fast(double %a) {
+; CHECK-LABEL: @exp2_strict_log2_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.log2.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp2.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call fast double @llvm.log2.f64(double %a)
+ %2 = call double @llvm.exp2.f64(double %1)
+ ret double %2
+}
+
+define double @exp2_log2_exp2_log2(double %a) {
+; CHECK-LABEL: @exp2_log2_exp2_log2(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log2.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp2.f64(double [[TMP1]])
+; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.log2.f64(double [[TMP2]])
+; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.exp2.f64(double [[TMP3]])
+; CHECK-NEXT: ret double [[TMP4]]
+;
+ %1 = call double @llvm.log2.f64(double %a)
+ %2 = call double @llvm.exp2.f64(double %1)
+ %3 = call double @llvm.log2.f64(double %2)
+ %4 = call double @llvm.exp2.f64(double %3)
+ ret double %4
+}
+
+define double @exp2_log2_exp2_log2_fast(double %a) {
+; CHECK-LABEL: @exp2_log2_exp2_log2_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.log2.f64(double %a)
+ %2 = call fast double @llvm.exp2.f64(double %1)
+ %3 = call fast double @llvm.log2.f64(double %2)
+ %4 = call fast double @llvm.exp2.f64(double %3)
+ ret double %4
+}
diff --git a/test/Transforms/InstSimplify/extract-element.ll b/test/Transforms/InstSimplify/extract-element.ll
index 8ee75a603cd15..051478913127b 100644
--- a/test/Transforms/InstSimplify/extract-element.ll
+++ b/test/Transforms/InstSimplify/extract-element.ll
@@ -5,9 +5,43 @@
define i129 @vec_extract_negidx(<3 x i129> %a) {
; CHECK-LABEL: @vec_extract_negidx(
-; CHECK-NEXT: [[E1:%.*]] = extractelement <3 x i129> [[A:%.*]], i129 -1
-; CHECK-NEXT: ret i129 [[E1]]
+; CHECK-NEXT: ret i129 undef
;
%E1 = extractelement <3 x i129> %a, i129 -1
ret i129 %E1
}
+
+define i129 @vec_extract_out_of_bounds(<3 x i129> %a) {
+; CHECK-LABEL: @vec_extract_out_of_bounds(
+; CHECK-NEXT: ret i129 undef
+;
+ %E1 = extractelement <3 x i129> %a, i129 3
+ ret i129 %E1
+}
+
+define i129 @vec_extract_out_of_bounds2(<3 x i129> %a) {
+; CHECK-LABEL: @vec_extract_out_of_bounds2(
+; CHECK-NEXT: ret i129 undef
+;
+ %E1 = extractelement <3 x i129> %a, i129 999999999999999
+ ret i129 %E1
+}
+
+
+define i129 @vec_extract_undef_index(<3 x i129> %a) {
+; CHECK-LABEL: @vec_extract_undef_index(
+; CHECK-NEXT: ret i129 undef
+;
+ %E1 = extractelement <3 x i129> %a, i129 undef
+ ret i129 %E1
+}
+
+
+define i129 @vec_extract_in_bounds(<3 x i129> %a) {
+; CHECK-LABEL: @vec_extract_in_bounds(
+; CHECK-NEXT: %E1 = extractelement <3 x i129> %a, i129 2
+; CHECK-NEXT: ret i129 %E1
+;
+ %E1 = extractelement <3 x i129> %a, i129 2
+ ret i129 %E1
+}
diff --git a/test/Transforms/InstSimplify/fold-intrinsics.ll b/test/Transforms/InstSimplify/fold-intrinsics.ll
new file mode 100644
index 0000000000000..e484704e8a7a5
--- /dev/null
+++ b/test/Transforms/InstSimplify/fold-intrinsics.ll
@@ -0,0 +1,27 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare double @llvm.powi.f64(double, i32) nounwind readonly
+declare i32 @llvm.bswap.i32(i32)
+
+; A
+define i32 @test_bswap(i32 %a) nounwind {
+; CHECK-LABEL: @test_bswap(
+; CHECK-NEXT: ret i32 %a
+;
+ %tmp2 = tail call i32 @llvm.bswap.i32( i32 %a )
+ %tmp4 = tail call i32 @llvm.bswap.i32( i32 %tmp2 )
+ ret i32 %tmp4
+}
+
+define void @powi(double %V, double *%P) {
+ %B = tail call double @llvm.powi.f64(double %V, i32 0) nounwind
+ store volatile double %B, double* %P
+
+ %C = tail call double @llvm.powi.f64(double %V, i32 1) nounwind
+ store volatile double %C, double* %P
+
+ ret void
+; CHECK-LABEL: @powi(
+; CHECK: store volatile double 1.0
+; CHECK: store volatile double %V
+}
diff --git a/test/Transforms/InstSimplify/insertelement.ll b/test/Transforms/InstSimplify/insertelement.ll
index 3acd921cbad86..3524f2145acb0 100644
--- a/test/Transforms/InstSimplify/insertelement.ll
+++ b/test/Transforms/InstSimplify/insertelement.ll
@@ -23,3 +23,9 @@ define <4 x i32> @test4(<4 x i32> %A) {
; CHECK: ret <4 x i32> undef
ret <4 x i32> %I
}
+
+define <4 x i32> @test5(<4 x i32> %A) {
+ %I = insertelement <4 x i32> %A, i32 5, i64 undef
+ ; CHECK: ret <4 x i32> undef
+ ret <4 x i32> %I
+}
diff --git a/test/Transforms/InstSimplify/log-intrinsic.ll b/test/Transforms/InstSimplify/log-intrinsic.ll
new file mode 100644
index 0000000000000..5d9820e20baaf
--- /dev/null
+++ b/test/Transforms/InstSimplify/log-intrinsic.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare double @llvm.log.f64(double)
+declare double @llvm.exp.f64(double)
+
+define double @log_exp(double %a) {
+; CHECK-LABEL: @log_exp(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call double @llvm.exp.f64(double %a)
+ %2 = call double @llvm.log.f64(double %1)
+ ret double %2
+}
+
+define double @log_exp_fast(double %a) {
+; CHECK-LABEL: @log_exp_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.exp.f64(double %a)
+ %2 = call fast double @llvm.log.f64(double %1)
+ ret double %2
+}
+
+define double @log_fast_exp_strict(double %a) {
+; CHECK-LABEL: @log_fast_exp_strict(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call double @llvm.exp.f64(double %a)
+ %2 = call fast double @llvm.log.f64(double %1)
+ ret double %2
+}
+
+define double @log_strict_exp_fast(double %a) {
+; CHECK-LABEL: @log_strict_exp_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.exp.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call fast double @llvm.exp.f64(double %a)
+ %2 = call double @llvm.log.f64(double %1)
+ ret double %2
+}
+
+define double @log_exp_log_exp(double %a) {
+; CHECK-LABEL: @log_exp_log_exp(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log.f64(double [[TMP1]])
+; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp.f64(double [[TMP2]])
+; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.log.f64(double [[TMP3]])
+; CHECK-NEXT: ret double [[TMP4]]
+;
+ %1 = call double @llvm.exp.f64(double %a)
+ %2 = call double @llvm.log.f64(double %1)
+ %3 = call double @llvm.exp.f64(double %2)
+ %4 = call double @llvm.log.f64(double %3)
+ ret double %4
+}
+
+define double @log_exp_log_exp_fast(double %a) {
+; CHECK-LABEL: @log_exp_log_exp_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.exp.f64(double %a)
+ %2 = call fast double @llvm.log.f64(double %1)
+ %3 = call fast double @llvm.exp.f64(double %2)
+ %4 = call fast double @llvm.log.f64(double %3)
+ ret double %4
+}
diff --git a/test/Transforms/InstSimplify/log2-intrinsic.ll b/test/Transforms/InstSimplify/log2-intrinsic.ll
new file mode 100644
index 0000000000000..dab0cdf979726
--- /dev/null
+++ b/test/Transforms/InstSimplify/log2-intrinsic.ll
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare double @llvm.log2.f64(double)
+declare double @llvm.exp2.f64(double)
+
+define double @log2_exp2(double %a) {
+; CHECK-LABEL: @log2_exp2(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log2.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call double @llvm.exp2.f64(double %a)
+ %2 = call double @llvm.log2.f64(double %1)
+ ret double %2
+}
+
+define double @log2_exp2_fast(double %a) {
+; CHECK-LABEL: @log2_exp2_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.exp2.f64(double %a)
+ %2 = call fast double @llvm.log2.f64(double %1)
+ ret double %2
+}
+
+define double @log2_fast_exp2_strict(double %a) {
+; CHECK-LABEL: @log2_fast_exp2_strict(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call double @llvm.exp2.f64(double %a)
+ %2 = call fast double @llvm.log2.f64(double %1)
+ ret double %2
+}
+
+define double @log2_strict_exp2_fast(double %a) {
+; CHECK-LABEL: @log2_strict_exp2_fast(
+; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.exp2.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log2.f64(double [[TMP1]])
+; CHECK-NEXT: ret double [[TMP2]]
+;
+ %1 = call fast double @llvm.exp2.f64(double %a)
+ %2 = call double @llvm.log2.f64(double %1)
+ ret double %2
+}
+
+define double @log2_exp2_log2_exp2(double %a) {
+; CHECK-LABEL: @log2_exp2_log2_exp2(
+; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log2.f64(double [[TMP1]])
+; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp2.f64(double [[TMP2]])
+; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.log2.f64(double [[TMP3]])
+; CHECK-NEXT: ret double [[TMP4]]
+;
+ %1 = call double @llvm.exp2.f64(double %a)
+ %2 = call double @llvm.log2.f64(double %1)
+ %3 = call double @llvm.exp2.f64(double %2)
+ %4 = call double @llvm.log2.f64(double %3)
+ ret double %4
+}
+
+define double @log2_exp2_log2_exp2_fast(double %a) {
+; CHECK-LABEL: @log2_exp2_log2_exp2_fast(
+; CHECK-NEXT: ret double [[A:%.*]]
+;
+ %1 = call fast double @llvm.exp2.f64(double %a)
+ %2 = call fast double @llvm.log2.f64(double %1)
+ %3 = call fast double @llvm.exp2.f64(double %2)
+ %4 = call fast double @llvm.log2.f64(double %3)
+ ret double %4
+}
diff --git a/test/Transforms/LoopRotate/pr35210.ll b/test/Transforms/LoopRotate/pr35210.ll
index 492922038b250..356c7db243b1d 100644
--- a/test/Transforms/LoopRotate/pr35210.ll
+++ b/test/Transforms/LoopRotate/pr35210.ll
@@ -9,8 +9,12 @@
; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on f
; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
; CHECK-NEXT: Running pass: FunctionToLoopPassAdaptor{{.*}} on f
+; CHECK-NEXT: Starting llvm::Function pass manager run.
+; CHECK-NEXT: Running pass: LoopSimplifyPass on f
; CHECK-NEXT: Running analysis: LoopAnalysis on f
; CHECK-NEXT: Running analysis: AssumptionAnalysis on f
+; CHECK-NEXT: Running pass: LCSSAPass on f
+; CHECK-NEXT: Finished llvm::Function pass manager run.
; CHECK-NEXT: Running analysis: AAManager on f
; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
diff --git a/test/Transforms/LoopSimplify/unreachable-loop-pred.ll b/test/Transforms/LoopSimplify/unreachable-loop-pred.ll
index 76b7bb21e468f..1e92ee4ee3bc6 100644
--- a/test/Transforms/LoopSimplify/unreachable-loop-pred.ll
+++ b/test/Transforms/LoopSimplify/unreachable-loop-pred.ll
@@ -18,3 +18,52 @@ while.body115: ; preds = %9, %if.end192, %if.
foo:
br label %while.body115
}
+
+; When loopsimplify generates dedicated exit block for blocks that are landing
+; pads (i.e. innerLoopExit in this test), we should not get confused with the
+; unreachable pred (unreachableB) to innerLoopExit.
+define align 8 void @baz(i32 %trip) personality i32* ()* @wobble {
+entry:
+ br label %outerHeader
+
+outerHeader:
+ invoke void @foo()
+ to label %innerPreheader unwind label %innerLoopExit
+
+innerPreheader:
+ br label %innerH
+
+innerH:
+ %tmp50 = invoke i8 * undef()
+ to label %innerLatch unwind label %innerLoopExit
+
+innerLatch:
+ %cmp = icmp slt i32 %trip, 42
+ br i1 %cmp, label %innerH, label %retblock
+
+unreachableB: ; No predecessors!
+ %tmp62 = invoke i8 * undef()
+ to label %retblock unwind label %innerLoopExit
+
+; undedicated exit block (preds from inner and outer loop)
+; Also has unreachableB as pred.
+innerLoopExit:
+ %tmp65 = landingpad { i8*, i32 }
+ cleanup
+ invoke void @foo()
+ to label %outerHeader unwind label %unwindblock
+
+unwindblock:
+ %tmp67 = landingpad { i8*, i32 }
+ cleanup
+ ret void
+
+retblock:
+ ret void
+}
+
+; Function Attrs: nounwind
+declare i32* @wobble()
+
+; Function Attrs: uwtable
+declare void @foo()
diff --git a/test/Transforms/SimplifyCFG/pr35774.ll b/test/Transforms/SimplifyCFG/pr35774.ll
new file mode 100644
index 0000000000000..149252085d517
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/pr35774.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -simplifycfg -S %s | FileCheck %s
+
+%foo = type { i32 (%foo)*, i32 }
+
+declare i32 @putchar(i32)
+
+define i32 @intercept(%foo %f) {
+; CHECK-LABEL: @intercept(
+; CHECK-NEXT: [[FN:%.*]] = extractvalue [[FOO:%.*]] %f, 0
+; CHECK-NEXT: [[X:%.*]] = extractvalue [[FOO]] %f, 1
+; CHECK-NEXT: [[X0:%.*]] = icmp eq i32 [[X]], 0
+; CHECK-NEXT: br i1 [[X0]], label [[ZERO:%.*]], label [[NONZERO:%.*]]
+; CHECK: Zero:
+; CHECK-NEXT: [[R0:%.*]] = musttail call i32 [[FN]](%foo [[F:%.*]])
+; CHECK-NEXT: ret i32 [[R0]]
+; CHECK: Nonzero:
+; CHECK-NEXT: [[R1:%.*]] = tail call i32 [[FN]](%foo [[F]])
+; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @putchar(i32 [[R1]])
+; CHECK-NEXT: ret i32 [[R1]]
+;
+ %fn = extractvalue %foo %f, 0
+ %x = extractvalue %foo %f, 1
+ %x0 = icmp eq i32 %x, 0
+ br i1 %x0, label %Zero, label %Nonzero
+
+Zero:
+ %r0 = musttail call i32 %fn(%foo %f)
+ ret i32 %r0
+
+Nonzero:
+ %r1 = tail call i32 %fn(%foo %f)
+ %1 = tail call i32 @putchar(i32 %r1)
+ ret i32 %r1
+}