From: Sanjay Patel Date: Tue, 26 Feb 2019 16:44:08 +0000 (+0000) Subject: [InstSimplify] add tests for rotate; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d20d79a027f4a1da52973f71802908f9f3de724;p=llvm [InstSimplify] add tests for rotate; NFC Rotate is a special-case of funnel shift that has different poison constraints than the general case. That's not visible yet in the existing tests, but it needs to be corrected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354894 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstSimplify/call.ll b/test/Transforms/InstSimplify/call.ll index 9d63d375afb..dfad3efe6f3 100644 --- a/test/Transforms/InstSimplify/call.ll +++ b/test/Transforms/InstSimplify/call.ll @@ -570,6 +570,106 @@ define i9 @fshr_zero_shift_guard_inverted_swapped(i9 %x, i9 %y, i9 %sh) { ret i9 %s } +; When the shift amount is 0, fshl returns its 1st parameter (x), so the guard is not needed. + +define i8 @rotl_zero_shift_guard(i8 %x, i8 %sh) { +; CHECK-LABEL: @rotl_zero_shift_guard( +; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[SH:%.*]]) +; CHECK-NEXT: ret i8 [[F]] +; + %c = icmp eq i8 %sh, 0 + %f = call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %sh) + %s = select i1 %c, i8 %x, i8 %f + ret i8 %s +} + +; When the shift amount is 0, fshl returns its 1st parameter (x), so the guard is not needed. + +define i8 @rotl_zero_shift_guard_swapped(i8 %x, i8 %sh) { +; CHECK-LABEL: @rotl_zero_shift_guard_swapped( +; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[SH:%.*]]) +; CHECK-NEXT: ret i8 [[F]] +; + %c = icmp ne i8 %sh, 0 + %f = call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %sh) + %s = select i1 %c, i8 %f, i8 %x + ret i8 %s +} + +; When the shift amount is 0, fshl returns its 1st parameter (x), so everything is deleted. + +define i8 @rotl_zero_shift_guard_inverted(i8 %x, i8 %sh) { +; CHECK-LABEL: @rotl_zero_shift_guard_inverted( +; CHECK-NEXT: ret i8 [[X:%.*]] +; + %c = icmp eq i8 %sh, 0 + %f = call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %sh) + %s = select i1 %c, i8 %f, i8 %x + ret i8 %s +} + +; When the shift amount is 0, fshl returns its 1st parameter (x), so everything is deleted. + +define i8 @rotl_zero_shift_guard_inverted_swapped(i8 %x, i8 %sh) { +; CHECK-LABEL: @rotl_zero_shift_guard_inverted_swapped( +; CHECK-NEXT: ret i8 [[X:%.*]] +; + %c = icmp ne i8 %sh, 0 + %f = call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %sh) + %s = select i1 %c, i8 %x, i8 %f + ret i8 %s +} + +; When the shift amount is 0, fshr returns its 2nd parameter (x), so the guard is not needed. + +define i9 @rotr_zero_shift_guard(i9 %x, i9 %sh) { +; CHECK-LABEL: @rotr_zero_shift_guard( +; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[X]], i9 [[SH:%.*]]) +; CHECK-NEXT: ret i9 [[F]] +; + %c = icmp eq i9 %sh, 0 + %f = call i9 @llvm.fshr.i9(i9 %x, i9 %x, i9 %sh) + %s = select i1 %c, i9 %x, i9 %f + ret i9 %s +} + +; When the shift amount is 0, fshr returns its 2nd parameter (x), so the guard is not needed. + +define i9 @rotr_zero_shift_guard_swapped(i9 %x, i9 %sh) { +; CHECK-LABEL: @rotr_zero_shift_guard_swapped( +; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[X]], i9 [[SH:%.*]]) +; CHECK-NEXT: ret i9 [[F]] +; + %c = icmp ne i9 %sh, 0 + %f = call i9 @llvm.fshr.i9(i9 %x, i9 %x, i9 %sh) + %s = select i1 %c, i9 %f, i9 %x + ret i9 %s +} + +; When the shift amount is 0, fshr returns its 2nd parameter (x), so everything is deleted. + +define i9 @rotr_zero_shift_guard_inverted(i9 %x, i9 %sh) { +; CHECK-LABEL: @rotr_zero_shift_guard_inverted( +; CHECK-NEXT: ret i9 [[X:%.*]] +; + %c = icmp eq i9 %sh, 0 + %f = call i9 @llvm.fshr.i9(i9 %x, i9 %x, i9 %sh) + %s = select i1 %c, i9 %f, i9 %x + ret i9 %s +} + +; When the shift amount is 0, fshr returns its 2nd parameter (x), so everything is deleted. + +define i9 @rotr_zero_shift_guard_inverted_swapped(i9 %x, i9 %sh) { +; CHECK-LABEL: @rotr_zero_shift_guard_inverted_swapped( +; CHECK-NEXT: ret i9 [[X:%.*]] +; + %c = icmp ne i9 %sh, 0 + %f = call i9 @llvm.fshr.i9(i9 %x, i9 %x, i9 %sh) + %s = select i1 %c, i9 %x, i9 %f + ret i9 %s +} + ; Negative test - make sure we're matching the correct parameter of fshl. define i8 @fshl_zero_shift_guard_wrong_select_op(i8 %x, i8 %y, i8 %sh) {