@@ -709,3 +709,146 @@ define i128 @test_sextinreg_i128(i128 %a) nounwind {
709
709
%res = call i128 @llvm.abs.i128 (i128 %ashr , i1 true )
710
710
ret i128 %res
711
711
}
712
+
713
+ define i8 @test_minsigned_i8 (i8 %a0 , i8 %a1 ) nounwind {
714
+ ; X64-LABEL: test_minsigned_i8:
715
+ ; X64: # %bb.0:
716
+ ; X64-NEXT: cmpb $-128, %dil
717
+ ; X64-NEXT: jne .LBB17_1
718
+ ; X64-NEXT: # %bb.2: # %select.end
719
+ ; X64-NEXT: movl %esi, %eax
720
+ ; X64-NEXT: retq
721
+ ; X64-NEXT: .LBB17_1: # %select.false.sink
722
+ ; X64-NEXT: movl %edi, %eax
723
+ ; X64-NEXT: sarb $7, %al
724
+ ; X64-NEXT: xorb %al, %dil
725
+ ; X64-NEXT: subb %al, %dil
726
+ ; X64-NEXT: movl %edi, %eax
727
+ ; X64-NEXT: retq
728
+ ;
729
+ ; X86-LABEL: test_minsigned_i8:
730
+ ; X86: # %bb.0:
731
+ ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
732
+ ; X86-NEXT: cmpb $-128, %al
733
+ ; X86-NEXT: jne .LBB17_1
734
+ ; X86-NEXT: # %bb.2: # %select.end
735
+ ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
736
+ ; X86-NEXT: retl
737
+ ; X86-NEXT: .LBB17_1: # %select.false.sink
738
+ ; X86-NEXT: movl %eax, %ecx
739
+ ; X86-NEXT: sarb $7, %cl
740
+ ; X86-NEXT: xorb %cl, %al
741
+ ; X86-NEXT: subb %cl, %al
742
+ ; X86-NEXT: retl
743
+ %lim = icmp eq i8 %a0 , -128
744
+ %abs = tail call i8 @llvm.abs.i8 (i8 %a0 , i1 false )
745
+ %res = select i1 %lim , i8 %a1 , i8 %abs
746
+ ret i8 %res
747
+ }
748
+
749
+ define i16 @test_minsigned_i16 (i16 %a0 , i16 %a1 ) nounwind {
750
+ ; X64-LABEL: test_minsigned_i16:
751
+ ; X64: # %bb.0:
752
+ ; X64-NEXT: movzwl %di, %eax
753
+ ; X64-NEXT: cmpl $32768, %eax # imm = 0x8000
754
+ ; X64-NEXT: jne .LBB18_1
755
+ ; X64-NEXT: # %bb.2: # %select.end
756
+ ; X64-NEXT: movl %esi, %eax
757
+ ; X64-NEXT: retq
758
+ ; X64-NEXT: .LBB18_1: # %select.false.sink
759
+ ; X64-NEXT: movl %edi, %eax
760
+ ; X64-NEXT: negw %ax
761
+ ; X64-NEXT: cmovsw %di, %ax
762
+ ; X64-NEXT: retq
763
+ ;
764
+ ; X86-LABEL: test_minsigned_i16:
765
+ ; X86: # %bb.0:
766
+ ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
767
+ ; X86-NEXT: cmpl $32768, %ecx # imm = 0x8000
768
+ ; X86-NEXT: jne .LBB18_1
769
+ ; X86-NEXT: # %bb.2: # %select.end
770
+ ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
771
+ ; X86-NEXT: retl
772
+ ; X86-NEXT: .LBB18_1: # %select.false.sink
773
+ ; X86-NEXT: movl %ecx, %eax
774
+ ; X86-NEXT: negw %ax
775
+ ; X86-NEXT: cmovsw %cx, %ax
776
+ ; X86-NEXT: retl
777
+ %lim = icmp eq i16 %a0 , -32768
778
+ %abs = tail call i16 @llvm.abs.i16 (i16 %a0 , i1 false )
779
+ %res = select i1 %lim , i16 %a1 , i16 %abs
780
+ ret i16 %res
781
+ }
782
+
783
+ define i32 @test_minsigned_i32 (i32 %a0 , i32 %a1 ) nounwind {
784
+ ; X64-LABEL: test_minsigned_i32:
785
+ ; X64: # %bb.0:
786
+ ; X64-NEXT: cmpl $-2147483648, %edi # imm = 0x80000000
787
+ ; X64-NEXT: jne .LBB19_1
788
+ ; X64-NEXT: # %bb.2: # %select.end
789
+ ; X64-NEXT: movl %esi, %eax
790
+ ; X64-NEXT: retq
791
+ ; X64-NEXT: .LBB19_1: # %select.false.sink
792
+ ; X64-NEXT: movl %edi, %eax
793
+ ; X64-NEXT: negl %eax
794
+ ; X64-NEXT: cmovsl %edi, %eax
795
+ ; X64-NEXT: retq
796
+ ;
797
+ ; X86-LABEL: test_minsigned_i32:
798
+ ; X86: # %bb.0:
799
+ ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
800
+ ; X86-NEXT: cmpl $-2147483648, %ecx # imm = 0x80000000
801
+ ; X86-NEXT: jne .LBB19_1
802
+ ; X86-NEXT: # %bb.2: # %select.end
803
+ ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
804
+ ; X86-NEXT: retl
805
+ ; X86-NEXT: .LBB19_1: # %select.false.sink
806
+ ; X86-NEXT: movl %ecx, %eax
807
+ ; X86-NEXT: negl %eax
808
+ ; X86-NEXT: cmovsl %ecx, %eax
809
+ ; X86-NEXT: retl
810
+ %lim = icmp eq i32 %a0 , -2147483648
811
+ %abs = tail call i32 @llvm.abs.i32 (i32 %a0 , i1 false )
812
+ %res = select i1 %lim , i32 %a1 , i32 %abs
813
+ ret i32 %res
814
+ }
815
+
816
+ define i64 @test_minsigned_i64 (i64 %a0 , i64 %a1 ) nounwind {
817
+ ; X64-LABEL: test_minsigned_i64:
818
+ ; X64: # %bb.0:
819
+ ; X64-NEXT: movabsq $-9223372036854775808, %rax # imm = 0x8000000000000000
820
+ ; X64-NEXT: cmpq %rax, %rdi
821
+ ; X64-NEXT: jne .LBB20_1
822
+ ; X64-NEXT: # %bb.2: # %select.end
823
+ ; X64-NEXT: movq %rsi, %rax
824
+ ; X64-NEXT: retq
825
+ ; X64-NEXT: .LBB20_1: # %select.false.sink
826
+ ; X64-NEXT: movq %rdi, %rax
827
+ ; X64-NEXT: negq %rax
828
+ ; X64-NEXT: cmovsq %rdi, %rax
829
+ ; X64-NEXT: retq
830
+ ;
831
+ ; X86-LABEL: test_minsigned_i64:
832
+ ; X86: # %bb.0:
833
+ ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
834
+ ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
835
+ ; X86-NEXT: leal -2147483648(%edx), %ecx
836
+ ; X86-NEXT: orl %eax, %ecx
837
+ ; X86-NEXT: jne .LBB20_1
838
+ ; X86-NEXT: # %bb.2: # %select.end
839
+ ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
840
+ ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
841
+ ; X86-NEXT: retl
842
+ ; X86-NEXT: .LBB20_1: # %select.false.sink
843
+ ; X86-NEXT: movl %edx, %ecx
844
+ ; X86-NEXT: sarl $31, %ecx
845
+ ; X86-NEXT: xorl %ecx, %edx
846
+ ; X86-NEXT: xorl %ecx, %eax
847
+ ; X86-NEXT: subl %ecx, %eax
848
+ ; X86-NEXT: sbbl %ecx, %edx
849
+ ; X86-NEXT: retl
850
+ %lim = icmp eq i64 %a0 , -9223372036854775808
851
+ %abs = tail call i64 @llvm.abs.i64 (i64 %a0 , i1 false )
852
+ %res = select i1 %lim , i64 %a1 , i64 %abs
853
+ ret i64 %res
854
+ }
0 commit comments