llvm.org GIT mirror llvm / 6c761e3
[NFC][InstCombine] Add a few extra srem-by-power-of-two tests - extra uses git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366652 91177308-0d34-0410-b5e6-96231b3b80d8 Roman Lebedev 29 days ago
1 changed file(s) with 37 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
700700 ret <2 x i1> %C
701701 }
702702
703 define i1 @test26(i32 %A, i32 %B) {
704 ; CHECK-LABEL: @test26(
705 ; CHECK-NEXT: [[C:%.*]] = shl nuw i32 1, [[B:%.*]]
706 ; CHECK-NEXT: [[D:%.*]] = srem i32 [[A:%.*]], [[C]]
707 ; CHECK-NEXT: [[E:%.*]] = icmp ne i32 [[D]], 0
708 ; CHECK-NEXT: ret i1 [[E]]
709 ;
710 %C = shl i32 1, %B ; not a constant
711 %D = srem i32 %A, %C
712 %E = icmp ne i32 %D, 0
713 ret i1 %E
714 }
715
716 define i1 @test27(i32 %A, i32* %remdst) {
717 ; CHECK-LABEL: @test27(
718 ; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], -2147483648
719 ; CHECK-NEXT: store i32 [[B]], i32* [[REMDST:%.*]], align 1
720 ; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], 0
721 ; CHECK-NEXT: ret i1 [[C]]
722 ;
723 %B = srem i32 %A, 2147483648 ; signbit
724 store i32 %B, i32* %remdst, align 1 ; extra use of rem
725 %C = icmp ne i32 %B, 0
726 ret i1 %C
727 }
728
729 define i1 @test28(i32 %A) {
730 ; CHECK-LABEL: @test28(
731 ; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], -2147483648
732 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[B]], 0
733 ; CHECK-NEXT: ret i1 [[C]]
734 ;
735 %B = srem i32 %A, 2147483648 ; signbit
736 %C = icmp eq i32 %B, 0 ; another equality predicate
737 ret i1 %C
738 }
739
703740 ; FP division-by-zero is not UB.
704741
705742 define double @PR34870(i1 %cond, double %x, double %y) {