From cb892e9066e53e794ff07247d43e588bfb65d520 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 4 Jan 2017 02:21:34 +0000 Subject: [InstCombine] Move casts around shift operations It is possible to perform a left shift before zero extending if the shift would only shift out zeros. llvm-svn: 290928 --- llvm/test/Transforms/InstCombine/shift.ll | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/test/Transforms/InstCombine/shift.ll') diff --git a/llvm/test/Transforms/InstCombine/shift.ll b/llvm/test/Transforms/InstCombine/shift.ll index dab212dc583..c046a72110c 100644 --- a/llvm/test/Transforms/InstCombine/shift.ll +++ b/llvm/test/Transforms/InstCombine/shift.ll @@ -1049,3 +1049,15 @@ define <2 x i65> @test_63(<2 x i64> %t) { %b = ashr <2 x i65> %sext, ret <2 x i65> %b } + +define i64 @test_64(i32 %t) { +; CHECK-LABEL: @test_64( +; CHECK-NEXT: [[SHL:%.*]] = shl i32 %t, 8 +; CHECK-NEXT: [[EXT:%.*]] = zext i32 [[SHL]] to i64 +; CHECK-NEXT: ret i64 [[EXT]] + + %and = and i32 %t, 16777215 + %ext = zext i32 %and to i64 + %shl = shl i64 %ext, 8 + ret i64 %shl +} -- cgit v1.2.3