From e385365c40fc6aa57341e804f7722ca41ca4df2b Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 14 Sep 2018 05:16:58 +0000 Subject: [PATCH] [InstCombine] Add some test cases for (add (sext x), (sext y)) --> (sext (add int x, y)) and (mul (sext x), (sext y)) --> (sext (mul x, y)). NFC llvm-svn: 342203 --- llvm/test/Transforms/InstCombine/sink-zext.ll | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/sink-zext.ll b/llvm/test/Transforms/InstCombine/sink-zext.ll index 25f6d91..1187235 100644 --- a/llvm/test/Transforms/InstCombine/sink-zext.ll +++ b/llvm/test/Transforms/InstCombine/sink-zext.ll @@ -328,4 +328,37 @@ define <2 x i64> @test10_vec(<2 x i32> %V) { ret <2 x i64> %mul } +define i64 @test11(i32 %V) { +; CHECK-LABEL: @test11( +; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !1 +; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !1 +; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw i32 [[CALL1]], [[CALL2]] +; CHECK-NEXT: [[ADD:%.*]] = sext i32 [[ADDCONV]] to i64 +; CHECK-NEXT: ret i64 [[ADD]] +; + %call1 = call i32 @callee(), !range !1 + %call2 = call i32 @callee(), !range !1 + %sext1 = sext i32 %call1 to i64 + %sext2 = sext i32 %call2 to i64 + %add = add i64 %sext1, %sext2 + ret i64 %add +} + +define i64 @test12(i32 %V) { +; CHECK-LABEL: @test12( +; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !1 +; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !1 +; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw i32 [[CALL1]], [[CALL2]] +; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[MULCONV]] to i64 +; CHECK-NEXT: ret i64 [[TMP1]] +; + %call1 = call i32 @callee(), !range !1 + %call2 = call i32 @callee(), !range !1 + %sext1 = sext i32 %call1 to i64 + %sext2 = sext i32 %call2 to i64 + %add = mul i64 %sext1, %sext2 + ret i64 %add +} + !0 = !{ i32 0, i32 2000 } +!1 = !{ i32 -2000, i32 0 } -- 2.7.4