@@ -938,3 +938,239 @@ define i128 @lshr_shl_mask(i128 %a0) {
938938 %2 = lshr i128 %1 , 1
939939 ret i128 %2
940940}
941+
942+ define i128 @shift_i128_limited_shamt (i128 noundef %a , i32 noundef %b ) {
943+ ; i686-LABEL: shift_i128_limited_shamt:
944+ ; i686: # %bb.0: # %start
945+ ; i686-NEXT: pushl %ebp
946+ ; i686-NEXT: .cfi_def_cfa_offset 8
947+ ; i686-NEXT: .cfi_offset %ebp, -8
948+ ; i686-NEXT: movl %esp, %ebp
949+ ; i686-NEXT: .cfi_def_cfa_register %ebp
950+ ; i686-NEXT: pushl %ebx
951+ ; i686-NEXT: pushl %edi
952+ ; i686-NEXT: pushl %esi
953+ ; i686-NEXT: andl $-16, %esp
954+ ; i686-NEXT: subl $48, %esp
955+ ; i686-NEXT: .cfi_offset %esi, -20
956+ ; i686-NEXT: .cfi_offset %edi, -16
957+ ; i686-NEXT: .cfi_offset %ebx, -12
958+ ; i686-NEXT: movzbl 40(%ebp), %eax
959+ ; i686-NEXT: movl 24(%ebp), %ecx
960+ ; i686-NEXT: movl 28(%ebp), %edx
961+ ; i686-NEXT: movl 32(%ebp), %esi
962+ ; i686-NEXT: movl 36(%ebp), %edi
963+ ; i686-NEXT: movl %edi, {{[0-9]+}}(%esp)
964+ ; i686-NEXT: movl %esi, {{[0-9]+}}(%esp)
965+ ; i686-NEXT: movl %edx, {{[0-9]+}}(%esp)
966+ ; i686-NEXT: movl %ecx, {{[0-9]+}}(%esp)
967+ ; i686-NEXT: movb $6, %cl
968+ ; i686-NEXT: subb %al, %cl
969+ ; i686-NEXT: movl %ecx, %eax
970+ ; i686-NEXT: shrb $3, %al
971+ ; i686-NEXT: andb $12, %al
972+ ; i686-NEXT: negb %al
973+ ; i686-NEXT: movsbl %al, %eax
974+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
975+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
976+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
977+ ; i686-NEXT: movl $0, (%esp)
978+ ; i686-NEXT: movl 20(%esp,%eax), %edx
979+ ; i686-NEXT: movl 24(%esp,%eax), %ebx
980+ ; i686-NEXT: movl %ebx, %edi
981+ ; i686-NEXT: shldl %cl, %edx, %edi
982+ ; i686-NEXT: movl 16(%esp,%eax), %esi
983+ ; i686-NEXT: movl 28(%esp,%eax), %eax
984+ ; i686-NEXT: shldl %cl, %ebx, %eax
985+ ; i686-NEXT: movl 8(%ebp), %ebx
986+ ; i686-NEXT: movl %eax, 12(%ebx)
987+ ; i686-NEXT: movl %edi, 8(%ebx)
988+ ; i686-NEXT: movl %esi, %eax
989+ ; i686-NEXT: shll %cl, %eax
990+ ; i686-NEXT: shldl %cl, %esi, %edx
991+ ; i686-NEXT: movl %edx, 4(%ebx)
992+ ; i686-NEXT: movl %eax, (%ebx)
993+ ; i686-NEXT: movl %ebx, %eax
994+ ; i686-NEXT: leal -12(%ebp), %esp
995+ ; i686-NEXT: popl %esi
996+ ; i686-NEXT: popl %edi
997+ ; i686-NEXT: popl %ebx
998+ ; i686-NEXT: popl %ebp
999+ ; i686-NEXT: .cfi_def_cfa %esp, 4
1000+ ; i686-NEXT: retl $4
1001+ ;
1002+ ; x86_64-LABEL: shift_i128_limited_shamt:
1003+ ; x86_64: # %bb.0: # %start
1004+ ; x86_64-NEXT: movb $6, %cl
1005+ ; x86_64-NEXT: subb %dl, %cl
1006+ ; x86_64-NEXT: shldq %cl, %rdi, %rsi
1007+ ; x86_64-NEXT: shlq %cl, %rdi
1008+ ; x86_64-NEXT: xorl %eax, %eax
1009+ ; x86_64-NEXT: testb $64, %cl
1010+ ; x86_64-NEXT: cmovneq %rdi, %rsi
1011+ ; x86_64-NEXT: cmoveq %rdi, %rax
1012+ ; x86_64-NEXT: movq %rsi, %rdx
1013+ ; x86_64-NEXT: retq
1014+ start:
1015+ %shamt = sub nuw nsw i32 6 , %b
1016+ %ext = zext nneg i32 %shamt to i128
1017+ %res = shl i128 %a , %ext
1018+ ret i128 %res
1019+ }
1020+
1021+ define i128 @shift_i128_limited_shamt_no_nuw (i128 noundef %a , i32 noundef %b ) {
1022+ ; i686-LABEL: shift_i128_limited_shamt_no_nuw:
1023+ ; i686: # %bb.0: # %start
1024+ ; i686-NEXT: pushl %ebp
1025+ ; i686-NEXT: .cfi_def_cfa_offset 8
1026+ ; i686-NEXT: .cfi_offset %ebp, -8
1027+ ; i686-NEXT: movl %esp, %ebp
1028+ ; i686-NEXT: .cfi_def_cfa_register %ebp
1029+ ; i686-NEXT: pushl %ebx
1030+ ; i686-NEXT: pushl %edi
1031+ ; i686-NEXT: pushl %esi
1032+ ; i686-NEXT: andl $-16, %esp
1033+ ; i686-NEXT: subl $48, %esp
1034+ ; i686-NEXT: .cfi_offset %esi, -20
1035+ ; i686-NEXT: .cfi_offset %edi, -16
1036+ ; i686-NEXT: .cfi_offset %ebx, -12
1037+ ; i686-NEXT: movzbl 40(%ebp), %eax
1038+ ; i686-NEXT: movl 24(%ebp), %ecx
1039+ ; i686-NEXT: movl 28(%ebp), %edx
1040+ ; i686-NEXT: movl 32(%ebp), %esi
1041+ ; i686-NEXT: movl 36(%ebp), %edi
1042+ ; i686-NEXT: movl %edi, {{[0-9]+}}(%esp)
1043+ ; i686-NEXT: movl %esi, {{[0-9]+}}(%esp)
1044+ ; i686-NEXT: movl %edx, {{[0-9]+}}(%esp)
1045+ ; i686-NEXT: movl %ecx, {{[0-9]+}}(%esp)
1046+ ; i686-NEXT: movb $6, %cl
1047+ ; i686-NEXT: subb %al, %cl
1048+ ; i686-NEXT: movl %ecx, %eax
1049+ ; i686-NEXT: shrb $3, %al
1050+ ; i686-NEXT: andb $12, %al
1051+ ; i686-NEXT: negb %al
1052+ ; i686-NEXT: movsbl %al, %eax
1053+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
1054+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
1055+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
1056+ ; i686-NEXT: movl $0, (%esp)
1057+ ; i686-NEXT: movl 20(%esp,%eax), %edx
1058+ ; i686-NEXT: movl 24(%esp,%eax), %ebx
1059+ ; i686-NEXT: movl %ebx, %edi
1060+ ; i686-NEXT: shldl %cl, %edx, %edi
1061+ ; i686-NEXT: movl 16(%esp,%eax), %esi
1062+ ; i686-NEXT: movl 28(%esp,%eax), %eax
1063+ ; i686-NEXT: shldl %cl, %ebx, %eax
1064+ ; i686-NEXT: movl 8(%ebp), %ebx
1065+ ; i686-NEXT: movl %eax, 12(%ebx)
1066+ ; i686-NEXT: movl %edi, 8(%ebx)
1067+ ; i686-NEXT: movl %esi, %eax
1068+ ; i686-NEXT: shll %cl, %eax
1069+ ; i686-NEXT: shldl %cl, %esi, %edx
1070+ ; i686-NEXT: movl %edx, 4(%ebx)
1071+ ; i686-NEXT: movl %eax, (%ebx)
1072+ ; i686-NEXT: movl %ebx, %eax
1073+ ; i686-NEXT: leal -12(%ebp), %esp
1074+ ; i686-NEXT: popl %esi
1075+ ; i686-NEXT: popl %edi
1076+ ; i686-NEXT: popl %ebx
1077+ ; i686-NEXT: popl %ebp
1078+ ; i686-NEXT: .cfi_def_cfa %esp, 4
1079+ ; i686-NEXT: retl $4
1080+ ;
1081+ ; x86_64-LABEL: shift_i128_limited_shamt_no_nuw:
1082+ ; x86_64: # %bb.0: # %start
1083+ ; x86_64-NEXT: movb $6, %cl
1084+ ; x86_64-NEXT: subb %dl, %cl
1085+ ; x86_64-NEXT: shldq %cl, %rdi, %rsi
1086+ ; x86_64-NEXT: shlq %cl, %rdi
1087+ ; x86_64-NEXT: xorl %eax, %eax
1088+ ; x86_64-NEXT: testb $64, %cl
1089+ ; x86_64-NEXT: cmovneq %rdi, %rsi
1090+ ; x86_64-NEXT: cmoveq %rdi, %rax
1091+ ; x86_64-NEXT: movq %rsi, %rdx
1092+ ; x86_64-NEXT: retq
1093+ start:
1094+ %shamt = sub nsw i32 6 , %b
1095+ %ext = zext nneg i32 %shamt to i128
1096+ %res = shl i128 %a , %ext
1097+ ret i128 %res
1098+ }
1099+
1100+ define i128 @shift_i128_limited_shamt_unknown_lhs (i128 noundef %a , i32 noundef %b , i32 noundef %c ) {
1101+ ; i686-LABEL: shift_i128_limited_shamt_unknown_lhs:
1102+ ; i686: # %bb.0: # %start
1103+ ; i686-NEXT: pushl %ebp
1104+ ; i686-NEXT: .cfi_def_cfa_offset 8
1105+ ; i686-NEXT: .cfi_offset %ebp, -8
1106+ ; i686-NEXT: movl %esp, %ebp
1107+ ; i686-NEXT: .cfi_def_cfa_register %ebp
1108+ ; i686-NEXT: pushl %ebx
1109+ ; i686-NEXT: pushl %edi
1110+ ; i686-NEXT: pushl %esi
1111+ ; i686-NEXT: andl $-16, %esp
1112+ ; i686-NEXT: subl $48, %esp
1113+ ; i686-NEXT: .cfi_offset %esi, -20
1114+ ; i686-NEXT: .cfi_offset %edi, -16
1115+ ; i686-NEXT: .cfi_offset %ebx, -12
1116+ ; i686-NEXT: movl 24(%ebp), %eax
1117+ ; i686-NEXT: movl 28(%ebp), %edx
1118+ ; i686-NEXT: movl 32(%ebp), %esi
1119+ ; i686-NEXT: movl 36(%ebp), %edi
1120+ ; i686-NEXT: movl 44(%ebp), %ecx
1121+ ; i686-NEXT: subl 40(%ebp), %ecx
1122+ ; i686-NEXT: movl %edi, {{[0-9]+}}(%esp)
1123+ ; i686-NEXT: movl %esi, {{[0-9]+}}(%esp)
1124+ ; i686-NEXT: movl %edx, {{[0-9]+}}(%esp)
1125+ ; i686-NEXT: movl %eax, {{[0-9]+}}(%esp)
1126+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
1127+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
1128+ ; i686-NEXT: movl $0, {{[0-9]+}}(%esp)
1129+ ; i686-NEXT: movl $0, (%esp)
1130+ ; i686-NEXT: movl %ecx, %eax
1131+ ; i686-NEXT: shrb $3, %al
1132+ ; i686-NEXT: andb $12, %al
1133+ ; i686-NEXT: negb %al
1134+ ; i686-NEXT: movsbl %al, %eax
1135+ ; i686-NEXT: movl 20(%esp,%eax), %edx
1136+ ; i686-NEXT: movl 24(%esp,%eax), %ebx
1137+ ; i686-NEXT: movl %ebx, %edi
1138+ ; i686-NEXT: shldl %cl, %edx, %edi
1139+ ; i686-NEXT: movl 16(%esp,%eax), %esi
1140+ ; i686-NEXT: movl 28(%esp,%eax), %eax
1141+ ; i686-NEXT: shldl %cl, %ebx, %eax
1142+ ; i686-NEXT: movl 8(%ebp), %ebx
1143+ ; i686-NEXT: movl %eax, 12(%ebx)
1144+ ; i686-NEXT: movl %edi, 8(%ebx)
1145+ ; i686-NEXT: movl %esi, %eax
1146+ ; i686-NEXT: shll %cl, %eax
1147+ ; i686-NEXT: # kill: def $cl killed $cl killed $ecx
1148+ ; i686-NEXT: shldl %cl, %esi, %edx
1149+ ; i686-NEXT: movl %edx, 4(%ebx)
1150+ ; i686-NEXT: movl %eax, (%ebx)
1151+ ; i686-NEXT: movl %ebx, %eax
1152+ ; i686-NEXT: leal -12(%ebp), %esp
1153+ ; i686-NEXT: popl %esi
1154+ ; i686-NEXT: popl %edi
1155+ ; i686-NEXT: popl %ebx
1156+ ; i686-NEXT: popl %ebp
1157+ ; i686-NEXT: .cfi_def_cfa %esp, 4
1158+ ; i686-NEXT: retl $4
1159+ ;
1160+ ; x86_64-LABEL: shift_i128_limited_shamt_unknown_lhs:
1161+ ; x86_64: # %bb.0: # %start
1162+ ; x86_64-NEXT: subl %edx, %ecx
1163+ ; x86_64-NEXT: shldq %cl, %rdi, %rsi
1164+ ; x86_64-NEXT: shlq %cl, %rdi
1165+ ; x86_64-NEXT: xorl %eax, %eax
1166+ ; x86_64-NEXT: testb $64, %cl
1167+ ; x86_64-NEXT: cmovneq %rdi, %rsi
1168+ ; x86_64-NEXT: cmoveq %rdi, %rax
1169+ ; x86_64-NEXT: movq %rsi, %rdx
1170+ ; x86_64-NEXT: retq
1171+ start:
1172+ %shamt = sub nuw nsw i32 %c , %b
1173+ %ext = zext nneg i32 %shamt to i128
1174+ %res = shl i128 %a , %ext
1175+ ret i128 %res
1176+ }
0 commit comments