forked from OSchip/llvm-project
				
			[InstCombine] add more splat tests with undef elements; NFC
This commit is contained in:
		
							parent
							
								
									104800084f
								
							
						
					
					
						commit
						2a191cf850
					
				|  | @ -1468,9 +1468,52 @@ define <4 x i32> @splat_assoc_add(<4 x i32> %x, <4 x i32> %y) { | ||||||
|   ret <4 x i32> %r |   ret <4 x i32> %r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | ; Undefs in splat mask are replaced with defined splat index | ||||||
|  | 
 | ||||||
|  | define <4 x i32> @splat_assoc_add_undef_mask_elts(<4 x i32> %x, <4 x i32> %y) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_add_undef_mask_elts( | ||||||
|  | ; CHECK-NEXT:    [[TMP1:%.*]] = add <4 x i32> [[X:%.*]], <i32 42, i32 undef, i32 undef, i32 undef> | ||||||
|  | ; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> undef, <4 x i32> zeroinitializer | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[TMP2]], [[Y:%.*]] | ||||||
|  | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 undef, i32 undef> | ||||||
|  |   %a = add <4 x i32> %y, <i32 42, i32 42, i32 42, i32 42> | ||||||
|  |   %r = add <4 x i32> %splatx, %a | ||||||
|  |   ret <4 x i32> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ; Undefs in splat mask are replaced with defined splat index | ||||||
|  | 
 | ||||||
|  | define <4 x i32> @splat_assoc_add_undef_mask_elt_at_splat_index(<4 x i32> %x, <4 x i32> %y) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_add_undef_mask_elt_at_splat_index( | ||||||
|  | ; CHECK-NEXT:    [[TMP1:%.*]] = add <4 x i32> [[X:%.*]], <i32 42, i32 undef, i32 undef, i32 undef> | ||||||
|  | ; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> undef, <4 x i32> zeroinitializer | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[TMP2]], [[Y:%.*]] | ||||||
|  | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0> | ||||||
|  |   %a = add <4 x i32> %y, <i32 42, i32 42, i32 42, i32 42> | ||||||
|  |   %r = add <4 x i32> %splatx, %a | ||||||
|  |   ret <4 x i32> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
| define <4 x i32> @splat_assoc_add_undef_constant_elts(<4 x i32> %x, <4 x i32> %y) { | define <4 x i32> @splat_assoc_add_undef_constant_elts(<4 x i32> %x, <4 x i32> %y) { | ||||||
| ; CHECK-LABEL: @splat_assoc_add_undef_constant_elts( | ; CHECK-LABEL: @splat_assoc_add_undef_constant_elts( | ||||||
| ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer | ||||||
|  | ; CHECK-NEXT:    [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 42, i32 undef, i32 undef, i32 42> | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]] | ||||||
|  | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> zeroinitializer | ||||||
|  |   %a = add <4 x i32> %y, <i32 42, i32 undef, i32 undef, i32 42> | ||||||
|  |   %r = add <4 x i32> %splatx, %a | ||||||
|  |   ret <4 x i32> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | define <4 x i32> @splat_assoc_add_undef_constant_elt_at_splat_index(<4 x i32> %x, <4 x i32> %y) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_add_undef_constant_elt_at_splat_index( | ||||||
|  | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer | ||||||
| ; CHECK-NEXT:    [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 undef, i32 42, i32 undef, i32 42> | ; CHECK-NEXT:    [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 undef, i32 42, i32 undef, i32 42> | ||||||
| ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]] | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]] | ||||||
| ; CHECK-NEXT:    ret <4 x i32> [[R]] | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | @ -1481,6 +1524,45 @@ define <4 x i32> @splat_assoc_add_undef_constant_elts(<4 x i32> %x, <4 x i32> %y | ||||||
|   ret <4 x i32> %r |   ret <4 x i32> %r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | define <4 x i32> @splat_assoc_add_undef_mask_elts_undef_constant_elts(<4 x i32> %x, <4 x i32> %y) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_add_undef_mask_elts_undef_constant_elts( | ||||||
|  | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 0, i32 undef> | ||||||
|  | ; CHECK-NEXT:    [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 42, i32 undef, i32 undef, i32 42> | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]] | ||||||
|  | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 0, i32 undef> | ||||||
|  |   %a = add <4 x i32> %y, <i32 42, i32 undef, i32 undef, i32 42> | ||||||
|  |   %r = add <4 x i32> %splatx, %a | ||||||
|  |   ret <4 x i32> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | define <4 x i32> @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elts(<4 x i32> %x, <4 x i32> %y) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elts( | ||||||
|  | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0> | ||||||
|  | ; CHECK-NEXT:    [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 42, i32 undef, i32 undef, i32 42> | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]] | ||||||
|  | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0> | ||||||
|  |   %a = add <4 x i32> %y, <i32 42, i32 undef, i32 undef, i32 42> | ||||||
|  |   %r = add <4 x i32> %splatx, %a | ||||||
|  |   ret <4 x i32> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | define <4 x i32> @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elt_at_splat_index(<4 x i32> %x, <4 x i32> %y) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elt_at_splat_index( | ||||||
|  | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0> | ||||||
|  | ; CHECK-NEXT:    [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 undef, i32 42, i32 undef, i32 42> | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]] | ||||||
|  | ; CHECK-NEXT:    ret <4 x i32> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0> | ||||||
|  |   %a = add <4 x i32> %y, <i32 undef, i32 42, i32 undef, i32 42> | ||||||
|  |   %r = add <4 x i32> %splatx, %a | ||||||
|  |   ret <4 x i32> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
| ; Non-zero splat index; commute operands; FMF intersect | ; Non-zero splat index; commute operands; FMF intersect | ||||||
| 
 | 
 | ||||||
| define <2 x float> @splat_assoc_fmul(<2 x float> %x, <2 x float> %y) { | define <2 x float> @splat_assoc_fmul(<2 x float> %x, <2 x float> %y) { | ||||||
|  | @ -1500,7 +1582,7 @@ define <2 x float> @splat_assoc_fmul(<2 x float> %x, <2 x float> %y) { | ||||||
| 
 | 
 | ||||||
| define <3 x i8> @splat_assoc_mul(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | define <3 x i8> @splat_assoc_mul(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | ||||||
| ; CHECK-LABEL: @splat_assoc_mul( | ; CHECK-LABEL: @splat_assoc_mul( | ||||||
| ; CHECK-NEXT:    [[TMP1:%.*]] = mul <3 x i8> [[X:%.*]], [[Z:%.*]] | ; CHECK-NEXT:    [[TMP1:%.*]] = mul <3 x i8> [[Z:%.*]], [[X:%.*]] | ||||||
| ; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
| ; CHECK-NEXT:    [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]] | ; CHECK-NEXT:    [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]] | ||||||
| ; CHECK-NEXT:    ret <3 x i8> [[R]] | ; CHECK-NEXT:    ret <3 x i8> [[R]] | ||||||
|  | @ -1512,15 +1594,58 @@ define <3 x i8> @splat_assoc_mul(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | ||||||
|   ret <3 x i8> %r |   ret <3 x i8> %r | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define <3 x i8> @splat_assoc_mul_undef_elts(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | define <3 x i8> @splat_assoc_mul_undef_elt1(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | ||||||
| ; CHECK-LABEL: @splat_assoc_mul_undef_elts( | ; CHECK-LABEL: @splat_assoc_mul_undef_elt1( | ||||||
| ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 undef, i32 2> | ; CHECK-NEXT:    [[TMP1:%.*]] = mul <3 x i8> [[Z:%.*]], [[X:%.*]] | ||||||
|  | ; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]] | ||||||
|  | ; CHECK-NEXT:    ret <3 x i8> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <3 x i8> %x, <3 x i8> undef, <3 x i32> <i32 undef, i32 2, i32 2> | ||||||
|  |   %splatz = shufflevector <3 x i8> %z, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|  |   %a = mul nsw <3 x i8> %y, %splatz | ||||||
|  |   %r = mul nsw nuw <3 x i8> %a, %splatx | ||||||
|  |   ret <3 x i8> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | define <3 x i8> @splat_assoc_mul_undef_elt2(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_mul_undef_elt2( | ||||||
|  | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|  | ; CHECK-NEXT:    [[SPLATZ:%.*]] = shufflevector <3 x i8> [[Z:%.*]], <3 x i8> undef, <3 x i32> <i32 undef, i32 2, i32 2> | ||||||
|  | ; CHECK-NEXT:    [[A:%.*]] = mul nsw <3 x i8> [[SPLATZ]], [[Y:%.*]] | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = mul nuw nsw <3 x i8> [[A]], [[SPLATX]] | ||||||
|  | ; CHECK-NEXT:    ret <3 x i8> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <3 x i8> %x, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|  |   %splatz = shufflevector <3 x i8> %z, <3 x i8> undef, <3 x i32> <i32 undef, i32 2, i32 2> | ||||||
|  |   %a = mul nsw <3 x i8> %y, %splatz | ||||||
|  |   %r = mul nsw nuw <3 x i8> %a, %splatx | ||||||
|  |   ret <3 x i8> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | define <3 x i8> @splat_assoc_mul_undef_elt_at_splat_index1(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_mul_undef_elt_at_splat_index1( | ||||||
|  | ; CHECK-NEXT:    [[TMP1:%.*]] = mul <3 x i8> [[Z:%.*]], [[X:%.*]] | ||||||
|  | ; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|  | ; CHECK-NEXT:    [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]] | ||||||
|  | ; CHECK-NEXT:    ret <3 x i8> [[R]] | ||||||
|  | ; | ||||||
|  |   %splatx = shufflevector <3 x i8> %x, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 undef> | ||||||
|  |   %splatz = shufflevector <3 x i8> %z, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|  |   %a = mul nsw <3 x i8> %y, %splatz | ||||||
|  |   %r = mul nsw nuw <3 x i8> %a, %splatx | ||||||
|  |   ret <3 x i8> %r | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | define <3 x i8> @splat_assoc_mul_undef_elt_at_splat_index2(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) { | ||||||
|  | ; CHECK-LABEL: @splat_assoc_mul_undef_elt_at_splat_index2( | ||||||
|  | ; CHECK-NEXT:    [[SPLATX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
| ; CHECK-NEXT:    [[SPLATZ:%.*]] = shufflevector <3 x i8> [[Z:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 undef> | ; CHECK-NEXT:    [[SPLATZ:%.*]] = shufflevector <3 x i8> [[Z:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 undef> | ||||||
| ; CHECK-NEXT:    [[A:%.*]] = mul nsw <3 x i8> [[SPLATZ]], [[Y:%.*]] | ; CHECK-NEXT:    [[A:%.*]] = mul nsw <3 x i8> [[SPLATZ]], [[Y:%.*]] | ||||||
| ; CHECK-NEXT:    [[R:%.*]] = mul nuw nsw <3 x i8> [[A]], [[SPLATX]] | ; CHECK-NEXT:    [[R:%.*]] = mul nuw nsw <3 x i8> [[A]], [[SPLATX]] | ||||||
| ; CHECK-NEXT:    ret <3 x i8> [[R]] | ; CHECK-NEXT:    ret <3 x i8> [[R]] | ||||||
| ; | ; | ||||||
|   %splatx = shufflevector <3 x i8> %x, <3 x i8> undef, <3 x i32> <i32 2, i32 undef, i32 2> |   %splatx = shufflevector <3 x i8> %x, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2> | ||||||
|   %splatz = shufflevector <3 x i8> %z, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 undef> |   %splatz = shufflevector <3 x i8> %z, <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 undef> | ||||||
|   %a = mul nsw <3 x i8> %y, %splatz |   %a = mul nsw <3 x i8> %y, %splatz | ||||||
|   %r = mul nsw nuw <3 x i8> %a, %splatx |   %r = mul nsw nuw <3 x i8> %a, %splatx | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Sanjay Patel
						Sanjay Patel