llvm.org GIT mirror llvm / f226cc2
[NFC][InstCombine] Add srem-by-signbit tests - still can fold to bittest https://rise4fun.com/Alive/IIeS git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366642 91177308-0d34-0410-b5e6-96231b3b80d8 Roman Lebedev a month ago
1 changed file(s) with 46 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
366366 define i32 @test17(i32 %X) {
367367 ; CHECK-LABEL: @test17(
368368 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], 1
369 ; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32
370 ; CHECK-NEXT: ret i32 [[TMP2]]
369 ; CHECK-NEXT: [[A:%.*]] = zext i1 [[TMP1]] to i32
370 ; CHECK-NEXT: ret i32 [[A]]
371371 ;
372372 %A = urem i32 1, %X
373373 ret i32 %A
656656 ret <2 x i32> %mul
657657 }
658658
659 define i1 @test24(i32 %A) {
660 ; CHECK-LABEL: @test24(
661 ; CHECK-NEXT: [[B:%.*]] = and i32 [[A:%.*]], 2147483647
662 ; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], 0
663 ; CHECK-NEXT: ret i1 [[C]]
664 ;
665 %B = urem i32 %A, 2147483648 ; signbit
666 %C = icmp ne i32 %B, 0
667 ret i1 %C
668 }
669
670 define <2 x i1> @test24_vec(<2 x i32> %A) {
671 ; CHECK-LABEL: @test24_vec(
672 ; CHECK-NEXT: [[B:%.*]] = and <2 x i32> [[A:%.*]],
673 ; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer
674 ; CHECK-NEXT: ret <2 x i1> [[C]]
675 ;
676 %B = urem <2 x i32> %A,
677 %C = icmp ne <2 x i32> %B, zeroinitializer
678 ret <2 x i1> %C
679 }
680
681 define i1 @test25(i32 %A) {
682 ; CHECK-LABEL: @test25(
683 ; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], -2147483648
684 ; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], 0
685 ; CHECK-NEXT: ret i1 [[C]]
686 ;
687 %B = srem i32 %A, 2147483648 ; signbit
688 %C = icmp ne i32 %B, 0
689 ret i1 %C
690 }
691
692 define <2 x i1> @test25_vec(<2 x i32> %A) {
693 ; CHECK-LABEL: @test25_vec(
694 ; CHECK-NEXT: [[B:%.*]] = srem <2 x i32> [[A:%.*]],
695 ; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer
696 ; CHECK-NEXT: ret <2 x i1> [[C]]
697 ;
698 %B = srem <2 x i32> %A,
699 %C = icmp ne <2 x i32> %B, zeroinitializer
700 ret <2 x i1> %C
701 }
702
659703 ; FP division-by-zero is not UB.
660704
661705 define double @PR34870(i1 %cond, double %x, double %y) {