llvm.org GIT mirror llvm / 6e2055b
[X86] Add tests for opportunities to improve known bits for CTTZ and CTLZ. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301791 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 2 years ago
1 changed file(s) with 93 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
777777 %bsr = xor i32 %ctlz, 31
778778 ret i32 %bsr
779779 }
780
781 define i8 @cttz_i8_knownbits(i8 %x) {
782 ; X32-LABEL: cttz_i8_knownbits:
783 ; X32: # BB#0:
784 ; X32-NEXT: movb {{[0-9]+}}(%esp), %al
785 ; X32-NEXT: orb $2, %al
786 ; X32-NEXT: movzbl %al, %eax
787 ; X32-NEXT: bsfl %eax, %eax
788 ; X32-NEXT: andb $1, %al
789 ; X32-NEXT: # kill: %AL %AL %EAX
790 ; X32-NEXT: retl
791 ;
792 ; X64-LABEL: cttz_i8_knownbits:
793 ; X64: # BB#0:
794 ; X64-NEXT: orb $2, %dil
795 ; X64-NEXT: movzbl %dil, %eax
796 ; X64-NEXT: bsfl %eax, %eax
797 ; X64-NEXT: andb $1, %al
798 ; X64-NEXT: # kill: %AL %AL %EAX
799 ; X64-NEXT: retq
800 ;
801 ; X32-CLZ-LABEL: cttz_i8_knownbits:
802 ; X32-CLZ: # BB#0:
803 ; X32-CLZ-NEXT: movb {{[0-9]+}}(%esp), %al
804 ; X32-CLZ-NEXT: orb $2, %al
805 ; X32-CLZ-NEXT: movzbl %al, %eax
806 ; X32-CLZ-NEXT: tzcntl %eax, %eax
807 ; X32-CLZ-NEXT: andb $1, %al
808 ; X32-CLZ-NEXT: # kill: %AL %AL %EAX
809 ; X32-CLZ-NEXT: retl
810 ;
811 ; X64-CLZ-LABEL: cttz_i8_knownbits:
812 ; X64-CLZ: # BB#0:
813 ; X64-CLZ-NEXT: orb $2, %dil
814 ; X64-CLZ-NEXT: movzbl %dil, %eax
815 ; X64-CLZ-NEXT: tzcntl %eax, %eax
816 ; X64-CLZ-NEXT: andb $1, %al
817 ; X64-CLZ-NEXT: # kill: %AL %AL %EAX
818 ; X64-CLZ-NEXT: retq
819 %x2 = or i8 %x, 2
820 %tmp = call i8 @llvm.cttz.i8(i8 %x2, i1 true )
821 %tmp2 = and i8 %tmp, 1
822 ret i8 %tmp2
823 }
824
825 define i8 @ctlz_i8_knownbits(i8 %x) {
826 ; X32-LABEL: ctlz_i8_knownbits:
827 ; X32: # BB#0:
828 ; X32-NEXT: movb {{[0-9]+}}(%esp), %al
829 ; X32-NEXT: orb $64, %al
830 ; X32-NEXT: movzbl %al, %eax
831 ; X32-NEXT: bsrl %eax, %eax
832 ; X32-NEXT: notl %eax
833 ; X32-NEXT: andb $1, %al
834 ; X32-NEXT: # kill: %AL %AL %EAX
835 ; X32-NEXT: retl
836 ;
837 ; X64-LABEL: ctlz_i8_knownbits:
838 ; X64: # BB#0:
839 ; X64-NEXT: orb $64, %dil
840 ; X64-NEXT: movzbl %dil, %eax
841 ; X64-NEXT: bsrl %eax, %eax
842 ; X64-NEXT: notl %eax
843 ; X64-NEXT: andb $1, %al
844 ; X64-NEXT: # kill: %AL %AL %EAX
845 ; X64-NEXT: retq
846 ;
847 ; X32-CLZ-LABEL: ctlz_i8_knownbits:
848 ; X32-CLZ: # BB#0:
849 ; X32-CLZ-NEXT: movb {{[0-9]+}}(%esp), %al
850 ; X32-CLZ-NEXT: orb $64, %al
851 ; X32-CLZ-NEXT: movzbl %al, %eax
852 ; X32-CLZ-NEXT: lzcntl %eax, %eax
853 ; X32-CLZ-NEXT: addl $-24, %eax
854 ; X32-CLZ-NEXT: andb $1, %al
855 ; X32-CLZ-NEXT: # kill: %AL %AL %EAX
856 ; X32-CLZ-NEXT: retl
857 ;
858 ; X64-CLZ-LABEL: ctlz_i8_knownbits:
859 ; X64-CLZ: # BB#0:
860 ; X64-CLZ-NEXT: orb $64, %dil
861 ; X64-CLZ-NEXT: movzbl %dil, %eax
862 ; X64-CLZ-NEXT: lzcntl %eax, %eax
863 ; X64-CLZ-NEXT: addl $-24, %eax
864 ; X64-CLZ-NEXT: andb $1, %al
865 ; X64-CLZ-NEXT: # kill: %AL %AL %EAX
866 ; X64-CLZ-NEXT: retq
867
868 %x2 = or i8 %x, 64
869 %tmp = call i8 @llvm.ctlz.i8(i8 %x2, i1 true )
870 %tmp2 = and i8 %tmp, 1
871 ret i8 %tmp2
872 }