From 2778f56a40dba2efd6da9466a1405b4a097fb0b5 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 20 Nov 2018 17:30:09 +0000 Subject: [PATCH] [InstSimplify] add tests for funnel shift with undef operands; NFC These are part of D54666, so adding them here before the patch to show the baseline (currently unoptimized) results. Patch by: @nikic (Nikita Popov) llvm-svn: 347331 --- llvm/test/Transforms/InstSimplify/call.ll | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll index 3c054e3..4207a27 100644 --- a/llvm/test/Transforms/InstSimplify/call.ll +++ b/llvm/test/Transforms/InstSimplify/call.ll @@ -628,3 +628,43 @@ define <2 x i8> @fshr_zero_shift_guard_splat(<2 x i8> %x, <2 x i8> %y, <2 x i8> ret <2 x i8> %s } +; If first two operands of funnel shift are undef, the result is undef + +define i8 @fshl_ops_undef(i8 %shamt) { +; CHECK-LABEL: @fshl_ops_undef( +; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.fshl.i8(i8 undef, i8 undef, i8 [[SHAMT:%.*]]) +; CHECK-NEXT: ret i8 [[R]] +; + %r = call i8 @llvm.fshl.i8(i8 undef, i8 undef, i8 %shamt) + ret i8 %r +} + +define i9 @fshr_ops_undef(i9 %shamt) { +; CHECK-LABEL: @fshr_ops_undef( +; CHECK-NEXT: [[R:%.*]] = call i9 @llvm.fshr.i9(i9 undef, i9 undef, i9 [[SHAMT:%.*]]) +; CHECK-NEXT: ret i9 [[R]] +; + %r = call i9 @llvm.fshr.i9(i9 undef, i9 undef, i9 %shamt) + ret i9 %r +} + +; If shift amount is undef, treat it as zero, returning operand 0 or 1 + +define i8 @fshl_shift_undef(i8 %x, i8 %y) { +; CHECK-LABEL: @fshl_shift_undef( +; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 undef) +; CHECK-NEXT: ret i8 [[R]] +; + %r = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 undef) + ret i8 %r +} + +define i9 @fshr_shift_undef(i9 %x, i9 %y) { +; CHECK-LABEL: @fshr_shift_undef( +; CHECK-NEXT: [[R:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 undef) +; CHECK-NEXT: ret i9 [[R]] +; + %r = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 undef) + ret i9 %r +} + -- 2.7.4