@@ -1061,3 +1061,81 @@ if.else:
10611061 call void @f2 ()
10621062 unreachable
10631063}
1064+
1065+ define i8 @invert_bitcasted_icmp (<8 x i32 > %a , <8 x i32 > %b ) {
1066+ ; CHECK-LABEL: @invert_bitcasted_icmp(
1067+ ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <8 x i32> [[A:%.*]], [[B:%.*]]
1068+ ; CHECK-NEXT: [[MASK_AS_INT:%.*]] = bitcast <8 x i1> [[CMP]] to i8
1069+ ; CHECK-NEXT: ret i8 [[MASK_AS_INT]]
1070+ ;
1071+ %cmp = icmp sle <8 x i32 > %a , %b
1072+ %mask.as.int = bitcast <8 x i1 > %cmp to i8
1073+ %not = xor i8 %mask.as.int , 255
1074+ ret i8 %not
1075+ }
1076+
1077+ define i8 @invert_bitcasted_icmp_samesign (<8 x i32 > %a , <8 x i32 > %b ) {
1078+ ; CHECK-LABEL: @invert_bitcasted_icmp_samesign(
1079+ ; CHECK-NEXT: [[CMP:%.*]] = icmp samesign sgt <8 x i32> [[A:%.*]], [[B:%.*]]
1080+ ; CHECK-NEXT: [[MASK_AS_INT:%.*]] = bitcast <8 x i1> [[CMP]] to i8
1081+ ; CHECK-NEXT: ret i8 [[MASK_AS_INT]]
1082+ ;
1083+ %cmp = icmp samesign sle <8 x i32 > %a , %b
1084+ %mask.as.int = bitcast <8 x i1 > %cmp to i8
1085+ %not = xor i8 %mask.as.int , 255
1086+ ret i8 %not
1087+ }
1088+
1089+ define i8 @invert_bitcasted_icmp_multi_use_1 (<8 x i32 > %a , <8 x i32 > %b ) {
1090+ ; CHECK-LABEL: @invert_bitcasted_icmp_multi_use_1(
1091+ ; CHECK-NEXT: [[CMP:%.*]] = icmp sle <8 x i32> [[A:%.*]], [[B:%.*]]
1092+ ; CHECK-NEXT: call void (...) @llvm.fake.use(<8 x i1> [[CMP]])
1093+ ; CHECK-NEXT: [[MASK_AS_INT:%.*]] = bitcast <8 x i1> [[CMP]] to i8
1094+ ; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[MASK_AS_INT]], -1
1095+ ; CHECK-NEXT: ret i8 [[NOT]]
1096+ ;
1097+ %cmp = icmp sle <8 x i32 > %a , %b
1098+ call void (...) @llvm.fake.use (<8 x i1 > %cmp )
1099+ %mask.as.int = bitcast <8 x i1 > %cmp to i8
1100+ %not = xor i8 %mask.as.int , -1
1101+ ret i8 %not
1102+ }
1103+
1104+ define i8 @invert_bitcasted_icmp_multi_use_2 (<8 x i32 > %a , <8 x i32 > %b ) {
1105+ ; CHECK-LABEL: @invert_bitcasted_icmp_multi_use_2(
1106+ ; CHECK-NEXT: [[CMP:%.*]] = icmp sle <8 x i32> [[A:%.*]], [[B:%.*]]
1107+ ; CHECK-NEXT: [[MASK_AS_INT:%.*]] = bitcast <8 x i1> [[CMP]] to i8
1108+ ; CHECK-NEXT: call void (...) @llvm.fake.use(i8 [[MASK_AS_INT]])
1109+ ; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[MASK_AS_INT]], -1
1110+ ; CHECK-NEXT: ret i8 [[NOT]]
1111+ ;
1112+ %cmp = icmp sle <8 x i32 > %a , %b
1113+ %mask.as.int = bitcast <8 x i1 > %cmp to i8
1114+ call void (...) @llvm.fake.use (i8 %mask.as.int )
1115+ %not = xor i8 %mask.as.int , -1
1116+ ret i8 %not
1117+ }
1118+
1119+ define i8 @invert_bitcasted_fcmp (<8 x float > %a , <8 x float > %b ) {
1120+ ; CHECK-LABEL: @invert_bitcasted_fcmp(
1121+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp uge <8 x float> [[A:%.*]], [[B:%.*]]
1122+ ; CHECK-NEXT: [[MASK_AS_INT:%.*]] = bitcast <8 x i1> [[CMP]] to i8
1123+ ; CHECK-NEXT: ret i8 [[MASK_AS_INT]]
1124+ ;
1125+ %cmp = fcmp olt <8 x float > %a , %b
1126+ %mask.as.int = bitcast <8 x i1 > %cmp to i8
1127+ %not = xor i8 %mask.as.int , 255
1128+ ret i8 %not
1129+ }
1130+
1131+ define i8 @invert_bitcasted_fcmp_fast (<8 x float > %a , <8 x float > %b ) {
1132+ ; CHECK-LABEL: @invert_bitcasted_fcmp_fast(
1133+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp fast uge <8 x float> [[A:%.*]], [[B:%.*]]
1134+ ; CHECK-NEXT: [[MASK_AS_INT:%.*]] = bitcast <8 x i1> [[CMP]] to i8
1135+ ; CHECK-NEXT: ret i8 [[MASK_AS_INT]]
1136+ ;
1137+ %cmp = fcmp fast olt <8 x float > %a , %b
1138+ %mask.as.int = bitcast <8 x i1 > %cmp to i8
1139+ %not = xor i8 %mask.as.int , 255
1140+ ret i8 %not
1141+ }
0 commit comments