@@ -433,6 +433,19 @@ define <2 x i16> @and_bitcast_f32_to_v2i16_constant(float %a) {
433433 ret <2 x i16 > %and
434434}
435435
436+ define <2 x i16 > @and_bitcast_f32_to_v2i16 (float %a , float %b ) {
437+ ; CHECK-LABEL: @and_bitcast_f32_to_v2i16(
438+ ; CHECK-NEXT: [[BC1:%.*]] = bitcast float [[A:%.*]] to <2 x i16>
439+ ; CHECK-NEXT: [[BC2:%.*]] = bitcast float [[B:%.*]] to <2 x i16>
440+ ; CHECK-NEXT: [[AND:%.*]] = and <2 x i16> [[BC1]], [[BC2]]
441+ ; CHECK-NEXT: ret <2 x i16> [[AND]]
442+ ;
443+ %bc1 = bitcast float %a to <2 x i16 >
444+ %bc2 = bitcast float %b to <2 x i16 >
445+ %and = and <2 x i16 > %bc1 , %bc2
446+ ret <2 x i16 > %and
447+ }
448+
436449; Negative test: bitcast from vector float to scalar int (optimization should not apply)
437450define i64 @and_bitcast_v2f32_to_i64_constant (<2 x float > %a ) {
438451; CHECK-LABEL: @and_bitcast_v2f32_to_i64_constant(
@@ -445,6 +458,19 @@ define i64 @and_bitcast_v2f32_to_i64_constant(<2 x float> %a) {
445458 ret i64 %and
446459}
447460
461+ define i64 @and_bitcast_v2f32_to_i64 (<2 x float > %a , <2 x float > %b ) {
462+ ; CHECK-LABEL: @and_bitcast_v2f32_to_i64(
463+ ; CHECK-NEXT: [[BC1:%.*]] = bitcast <2 x float> [[A:%.*]] to i64
464+ ; CHECK-NEXT: [[BC2:%.*]] = bitcast <2 x float> [[B:%.*]] to i64
465+ ; CHECK-NEXT: [[AND:%.*]] = and i64 [[BC1]], [[BC2]]
466+ ; CHECK-NEXT: ret i64 [[AND]]
467+ ;
468+ %bc1 = bitcast <2 x float > %a to i64
469+ %bc2 = bitcast <2 x float > %b to i64
470+ %and = and i64 %bc1 , %bc2
471+ ret i64 %and
472+ }
473+
448474; Test no-op bitcast
449475define i16 @xor_bitcast_i16_to_i16_constant (i16 %a ) {
450476; CHECK-LABEL: @xor_bitcast_i16_to_i16_constant(
@@ -457,6 +483,19 @@ define i16 @xor_bitcast_i16_to_i16_constant(i16 %a) {
457483 ret i16 %or
458484}
459485
486+ define i16 @xor_bitcast_i16_to_i16 (i16 %a , i16 %b ) {
487+ ; CHECK-LABEL: @xor_bitcast_i16_to_i16(
488+ ; CHECK-NEXT: [[BC1:%.*]] = bitcast i16 [[A:%.*]] to i16
489+ ; CHECK-NEXT: [[BC2:%.*]] = bitcast i16 [[B:%.*]] to i16
490+ ; CHECK-NEXT: [[OR:%.*]] = xor i16 [[BC1]], [[BC2]]
491+ ; CHECK-NEXT: ret i16 [[OR]]
492+ ;
493+ %bc1 = bitcast i16 %a to i16
494+ %bc2 = bitcast i16 %b to i16
495+ %or = xor i16 %bc1 , %bc2
496+ ret i16 %or
497+ }
498+
460499; Test bitwise operations with integer vector to integer bitcast
461500define <16 x i1 > @xor_bitcast_i16_to_v16i1_constant (i16 %a ) {
462501; CHECK-LABEL: @xor_bitcast_i16_to_v16i1_constant(
@@ -469,6 +508,18 @@ define <16 x i1> @xor_bitcast_i16_to_v16i1_constant(i16 %a) {
469508 ret <16 x i1 > %or
470509}
471510
511+ define <16 x i1 > @xor_bitcast_i16_to_v16i1 (i16 %a , i16 %b ) {
512+ ; CHECK-LABEL: @xor_bitcast_i16_to_v16i1(
513+ ; CHECK-NEXT: [[B1:%.*]] = xor i16 [[A:%.*]], [[B:%.*]]
514+ ; CHECK-NEXT: [[BC3:%.*]] = bitcast i16 [[B1]] to <16 x i1>
515+ ; CHECK-NEXT: ret <16 x i1> [[BC3]]
516+ ;
517+ %bc1 = bitcast i16 %a to <16 x i1 >
518+ %bc2 = bitcast i16 %b to <16 x i1 >
519+ %or = xor <16 x i1 > %bc1 , %bc2
520+ ret <16 x i1 > %or
521+ }
522+
472523; Test bitwise operations with integer vector to integer bitcast
473524define i16 @or_bitcast_v16i1_to_i16_constant (<16 x i1 > %a ) {
474525; CHECK-LABEL: @or_bitcast_v16i1_to_i16_constant(
@@ -480,3 +531,16 @@ define i16 @or_bitcast_v16i1_to_i16_constant(<16 x i1> %a) {
480531 %or = or i16 %bc , 3
481532 ret i16 %or
482533}
534+
535+ define i16 @or_bitcast_v16i1_to_i16 (<16 x i1 > %a , <16 x i1 > %b ) {
536+ ; CHECK-LABEL: @or_bitcast_v16i1_to_i16(
537+ ; CHECK-NEXT: [[BC1:%.*]] = bitcast <16 x i1> [[A:%.*]] to i16
538+ ; CHECK-NEXT: [[BC2:%.*]] = bitcast <16 x i1> [[B:%.*]] to i16
539+ ; CHECK-NEXT: [[OR:%.*]] = or i16 [[BC1]], [[BC2]]
540+ ; CHECK-NEXT: ret i16 [[OR]]
541+ ;
542+ %bc1 = bitcast <16 x i1 > %a to i16
543+ %bc2 = bitcast <16 x i1 > %b to i16
544+ %or = or i16 %bc1 , %bc2
545+ ret i16 %or
546+ }
0 commit comments