llvm.org GIT mirror llvm / 530c44f
[InstSimplify] add more tests for funnel shift with select; NFC The cases are just different enough that we should have complete tests to avoid bugs from typos in the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346902 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 11 months ago
1 changed file(s) with 78 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
512512 ret i8 %s
513513 }
514514
515 define i8 @fshl_zero_shift_guard_swapped(i8 %x, i8 %y, i8 %sh) {
516 ; CHECK-LABEL: @fshl_zero_shift_guard_swapped(
517 ; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[SH:%.*]], 0
518 ; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[SH]])
519 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[F]], i8 [[X]]
520 ; CHECK-NEXT: ret i8 [[S]]
521 ;
522 %c = icmp ne i8 %sh, 0
523 %f = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %sh)
524 %s = select i1 %c, i8 %f, i8 %x
525 ret i8 %s
526 }
527
528 define i8 @fshl_zero_shift_guard_inverted(i8 %x, i8 %y, i8 %sh) {
529 ; CHECK-LABEL: @fshl_zero_shift_guard_inverted(
530 ; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[SH:%.*]], 0
531 ; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[SH]])
532 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[F]], i8 [[X]]
533 ; CHECK-NEXT: ret i8 [[S]]
534 ;
535 %c = icmp eq i8 %sh, 0
536 %f = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %sh)
537 %s = select i1 %c, i8 %f, i8 %x
538 ret i8 %s
539 }
540
541 define i8 @fshl_zero_shift_guard_inverted_swapped(i8 %x, i8 %y, i8 %sh) {
542 ; CHECK-LABEL: @fshl_zero_shift_guard_inverted_swapped(
543 ; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[SH:%.*]], 0
544 ; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[SH]])
545 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[F]]
546 ; CHECK-NEXT: ret i8 [[S]]
547 ;
548 %c = icmp ne i8 %sh, 0
549 %f = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %sh)
550 %s = select i1 %c, i8 %x, i8 %f
551 ret i8 %s
552 }
553
554 define i9 @fshr_zero_shift_guard(i9 %x, i9 %y, i9 %sh) {
555 ; CHECK-LABEL: @fshr_zero_shift_guard(
556 ; CHECK-NEXT: [[C:%.*]] = icmp eq i9 [[SH:%.*]], 0
557 ; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 [[SH]])
558 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i9 [[Y]], i9 [[F]]
559 ; CHECK-NEXT: ret i9 [[S]]
560 ;
561 %c = icmp eq i9 %sh, 0
562 %f = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 %sh)
563 %s = select i1 %c, i9 %y, i9 %f
564 ret i9 %s
565 }
566
515567 define i9 @fshr_zero_shift_guard_swapped(i9 %x, i9 %y, i9 %sh) {
516568 ; CHECK-LABEL: @fshr_zero_shift_guard_swapped(
517569 ; CHECK-NEXT: [[C:%.*]] = icmp ne i9 [[SH:%.*]], 0
525577 ret i9 %s
526578 }
527579
580 define i9 @fshr_zero_shift_guard_inverted(i9 %x, i9 %y, i9 %sh) {
581 ; CHECK-LABEL: @fshr_zero_shift_guard_inverted(
582 ; CHECK-NEXT: [[C:%.*]] = icmp eq i9 [[SH:%.*]], 0
583 ; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 [[SH]])
584 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i9 [[F]], i9 [[Y]]
585 ; CHECK-NEXT: ret i9 [[S]]
586 ;
587 %c = icmp eq i9 %sh, 0
588 %f = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 %sh)
589 %s = select i1 %c, i9 %f, i9 %y
590 ret i9 %s
591 }
592
593 define i9 @fshr_zero_shift_guard_inverted_swapped(i9 %x, i9 %y, i9 %sh) {
594 ; CHECK-LABEL: @fshr_zero_shift_guard_inverted_swapped(
595 ; CHECK-NEXT: [[C:%.*]] = icmp ne i9 [[SH:%.*]], 0
596 ; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 [[SH]])
597 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i9 [[Y]], i9 [[F]]
598 ; CHECK-NEXT: ret i9 [[S]]
599 ;
600 %c = icmp ne i9 %sh, 0
601 %f = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 %sh)
602 %s = select i1 %c, i9 %y, i9 %f
603 ret i9 %s
604 }
605
528606 define i8 @fshl_zero_shift_guard_wrong_select_op(i8 %x, i8 %y, i8 %sh) {
529607 ; CHECK-LABEL: @fshl_zero_shift_guard_wrong_select_op(
530608 ; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[SH:%.*]], 0
538616 ret i8 %s
539617 }
540618
541 define i9 @fshr_zero_shift_guard_swapped_select_order(i9 %x, i9 %y, i9 %sh) {
542 ; CHECK-LABEL: @fshr_zero_shift_guard_swapped_select_order(
543 ; CHECK-NEXT: [[C:%.*]] = icmp eq i9 [[SH:%.*]], 0
544 ; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 [[SH]])
545 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i9 [[F]], i9 [[Y]]
546 ; CHECK-NEXT: ret i9 [[S]]
547 ;
548 %c = icmp eq i9 %sh, 0
549 %f = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 %sh)
550 %s = select i1 %c, i9 %f, i9 %y
551 ret i9 %s
552 }
553
554619 define <2 x i8> @fshr_zero_shift_guard_splat(<2 x i8> %x, <2 x i8> %y, <2 x i8> %sh) {
555620 ; CHECK-LABEL: @fshr_zero_shift_guard_splat(
556621 ; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i8> [[SH:%.*]], zeroinitializer