brintos

brintos / llvm-project-archived public Read only

0
0
Text · 35.0 KiB · 04a35e1 Raw
928 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S -data-layout="e-n64" | FileCheck %s --check-prefixes=ANY,ANYLE,LE643; RUN: opt < %s -passes=instcombine -S -data-layout="e-n128" | FileCheck %s --check-prefixes=ANY,ANYLE,LE1284; RUN: opt < %s -passes=instcombine -S -data-layout="E-n64" | FileCheck %s --check-prefixes=ANY,ANYBE,BE645; RUN: opt < %s -passes=instcombine -S -data-layout="E-n128" | FileCheck %s --check-prefixes=ANY,ANYBE,BE1286 7; RUN: opt < %s -passes=instcombine -S -data-layout="e-n64" -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat | FileCheck %s --check-prefixes=ANY,ANYLE,LE648; RUN: opt < %s -passes=instcombine -S -data-layout="e-n128" -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat | FileCheck %s --check-prefixes=ANY,ANYLE,LE1289; RUN: opt < %s -passes=instcombine -S -data-layout="E-n64" -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat | FileCheck %s --check-prefixes=ANY,ANYBE,BE6410; RUN: opt < %s -passes=instcombine -S -data-layout="E-n128" -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat | FileCheck %s --check-prefixes=ANY,ANYBE,BE12811 12define i32 @extractelement_out_of_range(<2 x i32> %x) {13; ANY-LABEL: @extractelement_out_of_range(14; ANY-NEXT:    ret i32 poison15;16  %E1 = extractelement <2 x i32> %x, i8 1617  ret i32 %E118}19 20define i32 @extractelement_type_out_of_range(<2 x i32> %x) {21; ANY-LABEL: @extractelement_type_out_of_range(22; ANY-NEXT:    [[E1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 023; ANY-NEXT:    ret i32 [[E1]]24;25  %E1 = extractelement <2 x i32> %x, i128 026  ret i32 %E127}28 29define i32 @bitcasted_inselt_equal_num_elts(float %f) {30; ANY-LABEL: @bitcasted_inselt_equal_num_elts(31; ANY-NEXT:    [[R:%.*]] = bitcast float [[F:%.*]] to i3232; ANY-NEXT:    ret i32 [[R]]33;34  %vf = insertelement <4 x float> undef, float %f, i32 035  %vi = bitcast <4 x float> %vf to <4 x i32>36  %r = extractelement <4 x i32> %vi, i32 037  ret i32 %r38}39 40define i64 @test2(i64 %in) {41; ANY-LABEL: @test2(42; ANY-NEXT:    ret i64 [[IN:%.*]]43;44  %vec = insertelement <8 x i64> undef, i64 %in, i32 045  %splat = shufflevector <8 x i64> %vec, <8 x i64> undef, <8 x i32> zeroinitializer46  %add = add <8 x i64> %splat, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>47  %r = extractelement <8 x i64> %add, i32 048  ret i64 %r49}50 51define i32 @bitcasted_inselt_wide_source_zero_elt(i64 %x) {52; ANYLE-LABEL: @bitcasted_inselt_wide_source_zero_elt(53; ANYLE-NEXT:    [[R:%.*]] = trunc i64 [[X:%.*]] to i3254; ANYLE-NEXT:    ret i32 [[R]]55;56; ANYBE-LABEL: @bitcasted_inselt_wide_source_zero_elt(57; ANYBE-NEXT:    [[TMP1:%.*]] = lshr i64 [[X:%.*]], 3258; ANYBE-NEXT:    [[R:%.*]] = trunc nuw i64 [[TMP1]] to i3259; ANYBE-NEXT:    ret i32 [[R]]60;61  %i = insertelement <2 x i64> zeroinitializer, i64 %x, i32 062  %b = bitcast <2 x i64> %i to <4 x i32>63  %r = extractelement <4 x i32> %b, i32 064  ret i32 %r65}66 67define i16 @bitcasted_inselt_wide_source_modulo_elt(i64 %x) {68; ANYLE-LABEL: @bitcasted_inselt_wide_source_modulo_elt(69; ANYLE-NEXT:    [[R:%.*]] = trunc i64 [[X:%.*]] to i1670; ANYLE-NEXT:    ret i16 [[R]]71;72; ANYBE-LABEL: @bitcasted_inselt_wide_source_modulo_elt(73; ANYBE-NEXT:    [[TMP1:%.*]] = lshr i64 [[X:%.*]], 4874; ANYBE-NEXT:    [[R:%.*]] = trunc nuw i64 [[TMP1]] to i1675; ANYBE-NEXT:    ret i16 [[R]]76;77  %i = insertelement <2 x i64> undef, i64 %x, i32 178  %b = bitcast <2 x i64> %i to <8 x i16>79  %r = extractelement <8 x i16> %b, i32 480  ret i16 %r81}82 83define i32 @bitcasted_inselt_wide_source_not_modulo_elt(i64 %x) {84; ANYLE-LABEL: @bitcasted_inselt_wide_source_not_modulo_elt(85; ANYLE-NEXT:    [[TMP1:%.*]] = lshr i64 [[X:%.*]], 3286; ANYLE-NEXT:    [[R:%.*]] = trunc nuw i64 [[TMP1]] to i3287; ANYLE-NEXT:    ret i32 [[R]]88;89; ANYBE-LABEL: @bitcasted_inselt_wide_source_not_modulo_elt(90; ANYBE-NEXT:    [[R:%.*]] = trunc i64 [[X:%.*]] to i3291; ANYBE-NEXT:    ret i32 [[R]]92;93  %i = insertelement <2 x i64> undef, i64 %x, i32 094  %b = bitcast <2 x i64> %i to <4 x i32>95  %r = extractelement <4 x i32> %b, i32 196  ret i32 %r97}98 99define i8 @bitcasted_inselt_wide_source_not_modulo_elt_not_half(i32 %x) {100; ANYLE-LABEL: @bitcasted_inselt_wide_source_not_modulo_elt_not_half(101; ANYLE-NEXT:    [[TMP1:%.*]] = lshr i32 [[X:%.*]], 16102; ANYLE-NEXT:    [[R:%.*]] = trunc i32 [[TMP1]] to i8103; ANYLE-NEXT:    ret i8 [[R]]104;105; ANYBE-LABEL: @bitcasted_inselt_wide_source_not_modulo_elt_not_half(106; ANYBE-NEXT:    [[TMP1:%.*]] = lshr i32 [[X:%.*]], 8107; ANYBE-NEXT:    [[R:%.*]] = trunc i32 [[TMP1]] to i8108; ANYBE-NEXT:    ret i8 [[R]]109;110  %i = insertelement <2 x i32> undef, i32 %x, i32 0111  %b = bitcast <2 x i32> %i to <8 x i8>112  %r = extractelement <8 x i8> %b, i32 2113  ret i8 %r114}115 116define i3 @bitcasted_inselt_wide_source_not_modulo_elt_not_half_weird_types(i15 %x) {117; ANYLE-LABEL: @bitcasted_inselt_wide_source_not_modulo_elt_not_half_weird_types(118; ANYLE-NEXT:    [[TMP1:%.*]] = lshr i15 [[X:%.*]], 3119; ANYLE-NEXT:    [[R:%.*]] = trunc i15 [[TMP1]] to i3120; ANYLE-NEXT:    ret i3 [[R]]121;122; ANYBE-LABEL: @bitcasted_inselt_wide_source_not_modulo_elt_not_half_weird_types(123; ANYBE-NEXT:    [[TMP1:%.*]] = lshr i15 [[X:%.*]], 9124; ANYBE-NEXT:    [[R:%.*]] = trunc i15 [[TMP1]] to i3125; ANYBE-NEXT:    ret i3 [[R]]126;127  %i = insertelement <3 x i15> undef, i15 %x, i32 0128  %b = bitcast <3 x i15> %i to <15 x i3>129  %r = extractelement <15 x i3> %b, i32 1130  ret i3 %r131}132 133; Negative test for the above fold, but we can remove the insert here.134 135define i8 @bitcasted_inselt_wide_source_wrong_insert(<2 x i32> %v, i32 %x) {136; ANY-LABEL: @bitcasted_inselt_wide_source_wrong_insert(137; ANY-NEXT:    [[TMP1:%.*]] = bitcast <2 x i32> [[V:%.*]] to <8 x i8>138; ANY-NEXT:    [[R:%.*]] = extractelement <8 x i8> [[TMP1]], i64 2139; ANY-NEXT:    ret i8 [[R]]140;141  %i = insertelement <2 x i32> %v, i32 %x, i32 1142  %b = bitcast <2 x i32> %i to <8 x i8>143  %r = extractelement <8 x i8> %b, i32 2144  ret i8 %r145}146 147; Partial negative test for the above fold, extra uses are not allowed if shift is needed.148 149declare void @use(<8 x i8>)150 151define i8 @bitcasted_inselt_wide_source_uses(i32 %x) {152; ANYLE-LABEL: @bitcasted_inselt_wide_source_uses(153; ANYLE-NEXT:    [[I:%.*]] = insertelement <2 x i32> <i32 poison, i32 undef>, i32 [[X:%.*]], i64 0154; ANYLE-NEXT:    [[B:%.*]] = bitcast <2 x i32> [[I]] to <8 x i8>155; ANYLE-NEXT:    call void @use(<8 x i8> [[B]])156; ANYLE-NEXT:    [[R:%.*]] = extractelement <8 x i8> [[B]], i64 3157; ANYLE-NEXT:    ret i8 [[R]]158;159; ANYBE-LABEL: @bitcasted_inselt_wide_source_uses(160; ANYBE-NEXT:    [[I:%.*]] = insertelement <2 x i32> <i32 poison, i32 undef>, i32 [[X:%.*]], i64 0161; ANYBE-NEXT:    [[B:%.*]] = bitcast <2 x i32> [[I]] to <8 x i8>162; ANYBE-NEXT:    call void @use(<8 x i8> [[B]])163; ANYBE-NEXT:    [[R:%.*]] = trunc i32 [[X]] to i8164; ANYBE-NEXT:    ret i8 [[R]]165;166  %i = insertelement <2 x i32> undef, i32 %x, i32 0167  %b = bitcast <2 x i32> %i to <8 x i8>168  call void @use(<8 x i8> %b)169  %r = extractelement <8 x i8> %b, i32 3170  ret i8 %r171}172 173define float @bitcasted_inselt_to_FP(i64 %x) {174; ANYLE-LABEL: @bitcasted_inselt_to_FP(175; ANYLE-NEXT:    [[TMP1:%.*]] = lshr i64 [[X:%.*]], 32176; ANYLE-NEXT:    [[TMP2:%.*]] = trunc nuw i64 [[TMP1]] to i32177; ANYLE-NEXT:    [[R:%.*]] = bitcast i32 [[TMP2]] to float178; ANYLE-NEXT:    ret float [[R]]179;180; ANYBE-LABEL: @bitcasted_inselt_to_FP(181; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i64 [[X:%.*]] to i32182; ANYBE-NEXT:    [[R:%.*]] = bitcast i32 [[TMP1]] to float183; ANYBE-NEXT:    ret float [[R]]184;185  %i = insertelement <2 x i64> undef, i64 %x, i32 0186  %b = bitcast <2 x i64> %i to <4 x float>187  %r = extractelement <4 x float> %b, i32 1188  ret float %r189}190 191declare void @use_v2i128(<2 x i128>)192declare void @use_v8f32(<8 x float>)193 194define float @bitcasted_inselt_to_FP_uses(i128 %x) {195; ANY-LABEL: @bitcasted_inselt_to_FP_uses(196; ANY-NEXT:    [[I:%.*]] = insertelement <2 x i128> <i128 poison, i128 undef>, i128 [[X:%.*]], i64 0197; ANY-NEXT:    call void @use_v2i128(<2 x i128> [[I]])198; ANY-NEXT:    [[B:%.*]] = bitcast <2 x i128> [[I]] to <8 x float>199; ANY-NEXT:    [[R:%.*]] = extractelement <8 x float> [[B]], i64 1200; ANY-NEXT:    ret float [[R]]201;202  %i = insertelement <2 x i128> undef, i128 %x, i32 0203  call void @use_v2i128(<2 x i128> %i)204  %b = bitcast <2 x i128> %i to <8 x float>205  %r = extractelement <8 x float> %b, i32 1206  ret float %r207}208 209define float @bitcasted_inselt_to_FP_uses2(i128 %x) {210; ANY-LABEL: @bitcasted_inselt_to_FP_uses2(211; ANY-NEXT:    [[I:%.*]] = insertelement <2 x i128> <i128 poison, i128 undef>, i128 [[X:%.*]], i64 0212; ANY-NEXT:    [[B:%.*]] = bitcast <2 x i128> [[I]] to <8 x float>213; ANY-NEXT:    call void @use_v8f32(<8 x float> [[B]])214; ANY-NEXT:    [[R:%.*]] = extractelement <8 x float> [[B]], i64 1215; ANY-NEXT:    ret float [[R]]216;217  %i = insertelement <2 x i128> undef, i128 %x, i32 0218  %b = bitcast <2 x i128> %i to <8 x float>219  call void @use_v8f32(<8 x float> %b)220  %r = extractelement <8 x float> %b, i32 1221  ret float %r222}223 224define i32 @bitcasted_inselt_from_FP(double %x) {225; ANYLE-LABEL: @bitcasted_inselt_from_FP(226; ANYLE-NEXT:    [[TMP1:%.*]] = bitcast double [[X:%.*]] to i64227; ANYLE-NEXT:    [[TMP2:%.*]] = lshr i64 [[TMP1]], 32228; ANYLE-NEXT:    [[R:%.*]] = trunc nuw i64 [[TMP2]] to i32229; ANYLE-NEXT:    ret i32 [[R]]230;231; ANYBE-LABEL: @bitcasted_inselt_from_FP(232; ANYBE-NEXT:    [[TMP1:%.*]] = bitcast double [[X:%.*]] to i64233; ANYBE-NEXT:    [[R:%.*]] = trunc i64 [[TMP1]] to i32234; ANYBE-NEXT:    ret i32 [[R]]235;236  %i = insertelement <2 x double> undef, double %x, i32 0237  %b = bitcast <2 x double> %i to <4 x i32>238  %r = extractelement <4 x i32> %b, i32 1239  ret i32 %r240}241 242declare void @use_v2f64(<2 x double>)243declare void @use_v8i16(<8 x i16>)244 245define i16 @bitcasted_inselt_from_FP_uses(double %x) {246; ANY-LABEL: @bitcasted_inselt_from_FP_uses(247; ANY-NEXT:    [[I:%.*]] = insertelement <2 x double> <double poison, double undef>, double [[X:%.*]], i64 0248; ANY-NEXT:    call void @use_v2f64(<2 x double> [[I]])249; ANY-NEXT:    [[B:%.*]] = bitcast <2 x double> [[I]] to <8 x i16>250; ANY-NEXT:    [[R:%.*]] = extractelement <8 x i16> [[B]], i64 1251; ANY-NEXT:    ret i16 [[R]]252;253  %i = insertelement <2 x double> undef, double %x, i32 0254  call void @use_v2f64(<2 x double> %i)255  %b = bitcast <2 x double> %i to <8 x i16>256  %r = extractelement <8 x i16> %b, i32 1257  ret i16 %r258}259 260define i16 @bitcasted_inselt_from_FP_uses2(double %x) {261; ANY-LABEL: @bitcasted_inselt_from_FP_uses2(262; ANY-NEXT:    [[I:%.*]] = insertelement <2 x double> <double poison, double undef>, double [[X:%.*]], i64 0263; ANY-NEXT:    [[B:%.*]] = bitcast <2 x double> [[I]] to <8 x i16>264; ANY-NEXT:    call void @use_v8i16(<8 x i16> [[B]])265; ANY-NEXT:    [[R:%.*]] = extractelement <8 x i16> [[B]], i64 1266; ANY-NEXT:    ret i16 [[R]]267;268  %i = insertelement <2 x double> undef, double %x, i32 0269  %b = bitcast <2 x double> %i to <8 x i16>270  call void @use_v8i16(<8 x i16> %b)271  %r = extractelement <8 x i16> %b, i32 1272  ret i16 %r273}274 275define float @bitcasted_inselt_to_and_from_FP(double %x) {276; ANY-LABEL: @bitcasted_inselt_to_and_from_FP(277; ANY-NEXT:    [[I:%.*]] = insertelement <2 x double> poison, double [[X:%.*]], i64 0278; ANY-NEXT:    [[B:%.*]] = bitcast <2 x double> [[I]] to <4 x float>279; ANY-NEXT:    [[R:%.*]] = extractelement <4 x float> [[B]], i64 1280; ANY-NEXT:    ret float [[R]]281;282  %i = insertelement <2 x double> undef, double %x, i32 0283  %b = bitcast <2 x double> %i to <4 x float>284  %r = extractelement <4 x float> %b, i32 1285  ret float %r286}287 288define float @bitcasted_inselt_to_and_from_FP_uses(double %x) {289; ANY-LABEL: @bitcasted_inselt_to_and_from_FP_uses(290; ANY-NEXT:    [[I:%.*]] = insertelement <2 x double> <double poison, double undef>, double [[X:%.*]], i64 0291; ANY-NEXT:    call void @use_v2f64(<2 x double> [[I]])292; ANY-NEXT:    [[B:%.*]] = bitcast <2 x double> [[I]] to <4 x float>293; ANY-NEXT:    [[R:%.*]] = extractelement <4 x float> [[B]], i64 1294; ANY-NEXT:    ret float [[R]]295;296  %i = insertelement <2 x double> undef, double %x, i32 0297  call void @use_v2f64(<2 x double> %i)298  %b = bitcast <2 x double> %i to <4 x float>299  %r = extractelement <4 x float> %b, i32 1300  ret float %r301}302 303declare void @use_v4f32(<4 x float>)304 305define float @bitcasted_inselt_to_and_from_FP_uses2(double %x) {306; ANY-LABEL: @bitcasted_inselt_to_and_from_FP_uses2(307; ANY-NEXT:    [[I:%.*]] = insertelement <2 x double> <double poison, double undef>, double [[X:%.*]], i64 0308; ANY-NEXT:    [[B:%.*]] = bitcast <2 x double> [[I]] to <4 x float>309; ANY-NEXT:    call void @use_v4f32(<4 x float> [[B]])310; ANY-NEXT:    [[R:%.*]] = extractelement <4 x float> [[B]], i64 1311; ANY-NEXT:    ret float [[R]]312;313  %i = insertelement <2 x double> undef, double %x, i32 0314  %b = bitcast <2 x double> %i to <4 x float>315  call void @use_v4f32(<4 x float> %b)316  %r = extractelement <4 x float> %b, i32 1317  ret float %r318}319 320; This would crash/assert because the logic for collectShuffleElements()321; does not consider the possibility of invalid insert/extract operands.322 323define <4 x double> @invalid_extractelement(<2 x double> %a, <4 x double> %b, ptr %p) {324; ANY-LABEL: @invalid_extractelement(325; ANY-NEXT:    [[TMP1:%.*]] = shufflevector <2 x double> [[A:%.*]], <2 x double> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>326; ANY-NEXT:    [[T4:%.*]] = shufflevector <4 x double> [[B:%.*]], <4 x double> [[TMP1]], <4 x i32> <i32 0, i32 1, i32 4, i32 3>327; ANY-NEXT:    [[E:%.*]] = extractelement <4 x double> [[B]], i64 1328; ANY-NEXT:    store double [[E]], ptr [[P:%.*]], align 8329; ANY-NEXT:    ret <4 x double> [[T4]]330;331  %t3 = extractelement <2 x double> %a, i32 0332  %t4 = insertelement <4 x double> %b, double %t3, i32 2333  %e = extractelement <4 x double> %t4, i32 1334  store double %e, ptr %p335  %e1 = extractelement <2 x double> %a, i32 4 ; invalid index336  %r = insertelement <4 x double> %t4, double %e1, i64 0337  ret <4 x double> %r338}339 340; i32 is a desirable/supported type independent of data layout.341 342define i8 @bitcast_scalar_supported_type_index0(i32 %x) {343; ANYLE-LABEL: @bitcast_scalar_supported_type_index0(344; ANYLE-NEXT:    [[R:%.*]] = trunc i32 [[X:%.*]] to i8345; ANYLE-NEXT:    ret i8 [[R]]346;347; ANYBE-LABEL: @bitcast_scalar_supported_type_index0(348; ANYBE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 24349; ANYBE-NEXT:    [[R:%.*]] = trunc nuw i32 [[EXTELT_OFFSET]] to i8350; ANYBE-NEXT:    ret i8 [[R]]351;352  %v = bitcast i32 %x to <4 x i8>353  %r = extractelement <4 x i8> %v, i8 0354  ret i8 %r355}356 357define i8 @bitcast_scalar_supported_type_index2(i32 %x) {358; ANYLE-LABEL: @bitcast_scalar_supported_type_index2(359; ANYLE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 16360; ANYLE-NEXT:    [[R:%.*]] = trunc i32 [[EXTELT_OFFSET]] to i8361; ANYLE-NEXT:    ret i8 [[R]]362;363; ANYBE-LABEL: @bitcast_scalar_supported_type_index2(364; ANYBE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 8365; ANYBE-NEXT:    [[R:%.*]] = trunc i32 [[EXTELT_OFFSET]] to i8366; ANYBE-NEXT:    ret i8 [[R]]367;368  %v = bitcast i32 %x to <4 x i8>369  %r = extractelement <4 x i8> %v, i64 2370  ret i8 %r371}372 373; i64 is legal based on data layout.374 375define i4 @bitcast_scalar_legal_type_index3(i64 %x) {376; LE64-LABEL: @bitcast_scalar_legal_type_index3(377; LE64-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i64 [[X:%.*]], 12378; LE64-NEXT:    [[R:%.*]] = trunc i64 [[EXTELT_OFFSET]] to i4379; LE64-NEXT:    ret i4 [[R]]380;381; LE128-LABEL: @bitcast_scalar_legal_type_index3(382; LE128-NEXT:    [[V:%.*]] = bitcast i64 [[X:%.*]] to <16 x i4>383; LE128-NEXT:    [[R:%.*]] = extractelement <16 x i4> [[V]], i64 3384; LE128-NEXT:    ret i4 [[R]]385;386; BE64-LABEL: @bitcast_scalar_legal_type_index3(387; BE64-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i64 [[X:%.*]], 48388; BE64-NEXT:    [[R:%.*]] = trunc i64 [[EXTELT_OFFSET]] to i4389; BE64-NEXT:    ret i4 [[R]]390;391; BE128-LABEL: @bitcast_scalar_legal_type_index3(392; BE128-NEXT:    [[V:%.*]] = bitcast i64 [[X:%.*]] to <16 x i4>393; BE128-NEXT:    [[R:%.*]] = extractelement <16 x i4> [[V]], i64 3394; BE128-NEXT:    ret i4 [[R]]395;396 397  %v = bitcast i64 %x to <16 x i4>398  %r = extractelement <16 x i4> %v, i64 3399  ret i4 %r400}401 402; negative test - don't create a shift for an illegal type.403 404define i8 @bitcast_scalar_illegal_type_index1(i128 %x) {405; LE64-LABEL: @bitcast_scalar_illegal_type_index1(406; LE64-NEXT:    [[V:%.*]] = bitcast i128 [[X:%.*]] to <16 x i8>407; LE64-NEXT:    [[R:%.*]] = extractelement <16 x i8> [[V]], i64 1408; LE64-NEXT:    ret i8 [[R]]409;410; LE128-LABEL: @bitcast_scalar_illegal_type_index1(411; LE128-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i128 [[X:%.*]], 8412; LE128-NEXT:    [[R:%.*]] = trunc i128 [[EXTELT_OFFSET]] to i8413; LE128-NEXT:    ret i8 [[R]]414;415; BE64-LABEL: @bitcast_scalar_illegal_type_index1(416; BE64-NEXT:    [[V:%.*]] = bitcast i128 [[X:%.*]] to <16 x i8>417; BE64-NEXT:    [[R:%.*]] = extractelement <16 x i8> [[V]], i64 1418; BE64-NEXT:    ret i8 [[R]]419;420; BE128-LABEL: @bitcast_scalar_illegal_type_index1(421; BE128-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i128 [[X:%.*]], 112422; BE128-NEXT:    [[R:%.*]] = trunc i128 [[EXTELT_OFFSET]] to i8423; BE128-NEXT:    ret i8 [[R]]424;425  %v = bitcast i128 %x to <16 x i8>426  %r = extractelement <16 x i8> %v, i64 1427  ret i8 %r428}429 430; negative test - can't use shift/trunc on FP431 432define i8 @bitcast_fp_index0(float %x) {433; ANY-LABEL: @bitcast_fp_index0(434; ANY-NEXT:    [[V:%.*]] = bitcast float [[X:%.*]] to <4 x i8>435; ANY-NEXT:    [[R:%.*]] = extractelement <4 x i8> [[V]], i64 0436; ANY-NEXT:    ret i8 [[R]]437;438  %v = bitcast float %x to <4 x i8>439  %r = extractelement <4 x i8> %v, i8 0440  ret i8 %r441}442 443define half @bitcast_fp16vec_index0(i32 %x) {444; ANYLE-LABEL: @bitcast_fp16vec_index0(445; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i32 [[X:%.*]] to i16446; ANYLE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to half447; ANYLE-NEXT:    ret half [[R]]448;449; ANYBE-LABEL: @bitcast_fp16vec_index0(450; ANYBE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 16451; ANYBE-NEXT:    [[TMP1:%.*]] = trunc nuw i32 [[EXTELT_OFFSET]] to i16452; ANYBE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to half453; ANYBE-NEXT:    ret half [[R]]454;455  %v = bitcast i32 %x to <2 x half>456  %r = extractelement <2 x half> %v, i8 0457  ret half %r458}459 460define half @bitcast_fp16vec_index1(i32 %x) {461; ANYLE-LABEL: @bitcast_fp16vec_index1(462; ANYLE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 16463; ANYLE-NEXT:    [[TMP1:%.*]] = trunc nuw i32 [[EXTELT_OFFSET]] to i16464; ANYLE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to half465; ANYLE-NEXT:    ret half [[R]]466;467; ANYBE-LABEL: @bitcast_fp16vec_index1(468; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i32 [[X:%.*]] to i16469; ANYBE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to half470; ANYBE-NEXT:    ret half [[R]]471;472  %v = bitcast i32 %x to <2 x half>473  %r = extractelement <2 x half> %v, i8 1474  ret half %r475}476 477define bfloat @bitcast_bfp16vec_index0(i32 %x) {478; ANYLE-LABEL: @bitcast_bfp16vec_index0(479; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i32 [[X:%.*]] to i16480; ANYLE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to bfloat481; ANYLE-NEXT:    ret bfloat [[R]]482;483; ANYBE-LABEL: @bitcast_bfp16vec_index0(484; ANYBE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 16485; ANYBE-NEXT:    [[TMP1:%.*]] = trunc nuw i32 [[EXTELT_OFFSET]] to i16486; ANYBE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to bfloat487; ANYBE-NEXT:    ret bfloat [[R]]488;489  %v = bitcast i32 %x to <2 x bfloat>490  %r = extractelement <2 x bfloat> %v, i8 0491  ret bfloat %r492}493 494define bfloat @bitcast_bfp16vec_index1(i32 %x) {495; ANYLE-LABEL: @bitcast_bfp16vec_index1(496; ANYLE-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i32 [[X:%.*]], 16497; ANYLE-NEXT:    [[TMP1:%.*]] = trunc nuw i32 [[EXTELT_OFFSET]] to i16498; ANYLE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to bfloat499; ANYLE-NEXT:    ret bfloat [[R]]500;501; ANYBE-LABEL: @bitcast_bfp16vec_index1(502; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i32 [[X:%.*]] to i16503; ANYBE-NEXT:    [[R:%.*]] = bitcast i16 [[TMP1]] to bfloat504; ANYBE-NEXT:    ret bfloat [[R]]505;506  %v = bitcast i32 %x to <2 x bfloat>507  %r = extractelement <2 x bfloat> %v, i8 1508  ret bfloat %r509}510 511define float @bitcast_fp32vec_index0(i64 %x) {512; ANYLE-LABEL: @bitcast_fp32vec_index0(513; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i64 [[X:%.*]] to i32514; ANYLE-NEXT:    [[R:%.*]] = bitcast i32 [[TMP1]] to float515; ANYLE-NEXT:    ret float [[R]]516;517; BE64-LABEL: @bitcast_fp32vec_index0(518; BE64-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i64 [[X:%.*]], 32519; BE64-NEXT:    [[TMP1:%.*]] = trunc nuw i64 [[EXTELT_OFFSET]] to i32520; BE64-NEXT:    [[R:%.*]] = bitcast i32 [[TMP1]] to float521; BE64-NEXT:    ret float [[R]]522;523; BE128-LABEL: @bitcast_fp32vec_index0(524; BE128-NEXT:    [[V:%.*]] = bitcast i64 [[X:%.*]] to <2 x float>525; BE128-NEXT:    [[R:%.*]] = extractelement <2 x float> [[V]], i64 0526; BE128-NEXT:    ret float [[R]]527;528  %v = bitcast i64 %x to <2 x float>529  %r = extractelement <2 x float> %v, i8 0530  ret float %r531}532 533define float @bitcast_fp32vec_index1(i64 %x) {534; LE64-LABEL: @bitcast_fp32vec_index1(535; LE64-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i64 [[X:%.*]], 32536; LE64-NEXT:    [[TMP1:%.*]] = trunc nuw i64 [[EXTELT_OFFSET]] to i32537; LE64-NEXT:    [[R:%.*]] = bitcast i32 [[TMP1]] to float538; LE64-NEXT:    ret float [[R]]539;540; LE128-LABEL: @bitcast_fp32vec_index1(541; LE128-NEXT:    [[V:%.*]] = bitcast i64 [[X:%.*]] to <2 x float>542; LE128-NEXT:    [[R:%.*]] = extractelement <2 x float> [[V]], i64 1543; LE128-NEXT:    ret float [[R]]544;545; ANYBE-LABEL: @bitcast_fp32vec_index1(546; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i64 [[X:%.*]] to i32547; ANYBE-NEXT:    [[R:%.*]] = bitcast i32 [[TMP1]] to float548; ANYBE-NEXT:    ret float [[R]]549;550  %v = bitcast i64 %x to <2 x float>551  %r = extractelement <2 x float> %v, i8 1552  ret float %r553}554 555define double @bitcast_fp64vec64_index0(i64 %x) {556; ANY-LABEL: @bitcast_fp64vec64_index0(557; ANY-NEXT:    [[R:%.*]] = bitcast i64 [[X:%.*]] to double558; ANY-NEXT:    ret double [[R]]559;560  %v = bitcast i64 %x to <1 x double>561  %r = extractelement <1 x double> %v, i8 0562  ret double %r563}564 565define double @bitcast_fp64vec_index0(i128 %x) {566; ANYLE-LABEL: @bitcast_fp64vec_index0(567; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i128 [[X:%.*]] to i64568; ANYLE-NEXT:    [[R:%.*]] = bitcast i64 [[TMP1]] to double569; ANYLE-NEXT:    ret double [[R]]570;571; BE64-LABEL: @bitcast_fp64vec_index0(572; BE64-NEXT:    [[V:%.*]] = bitcast i128 [[X:%.*]] to <2 x double>573; BE64-NEXT:    [[R:%.*]] = extractelement <2 x double> [[V]], i64 0574; BE64-NEXT:    ret double [[R]]575;576; BE128-LABEL: @bitcast_fp64vec_index0(577; BE128-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i128 [[X:%.*]], 64578; BE128-NEXT:    [[TMP1:%.*]] = trunc nuw i128 [[EXTELT_OFFSET]] to i64579; BE128-NEXT:    [[R:%.*]] = bitcast i64 [[TMP1]] to double580; BE128-NEXT:    ret double [[R]]581;582  %v = bitcast i128 %x to <2 x double>583  %r = extractelement <2 x double> %v, i8 0584  ret double %r585}586 587define double @bitcast_fp64vec_index1(i128 %x) {588; LE64-LABEL: @bitcast_fp64vec_index1(589; LE64-NEXT:    [[V:%.*]] = bitcast i128 [[X:%.*]] to <2 x double>590; LE64-NEXT:    [[R:%.*]] = extractelement <2 x double> [[V]], i64 1591; LE64-NEXT:    ret double [[R]]592;593; LE128-LABEL: @bitcast_fp64vec_index1(594; LE128-NEXT:    [[EXTELT_OFFSET:%.*]] = lshr i128 [[X:%.*]], 64595; LE128-NEXT:    [[TMP1:%.*]] = trunc nuw i128 [[EXTELT_OFFSET]] to i64596; LE128-NEXT:    [[R:%.*]] = bitcast i64 [[TMP1]] to double597; LE128-NEXT:    ret double [[R]]598;599; ANYBE-LABEL: @bitcast_fp64vec_index1(600; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i128 [[X:%.*]] to i64601; ANYBE-NEXT:    [[R:%.*]] = bitcast i64 [[TMP1]] to double602; ANYBE-NEXT:    ret double [[R]]603;604  %v = bitcast i128 %x to <2 x double>605  %r = extractelement <2 x double> %v, i8 1606  ret double %r607}608 609; negative test - input integer should be legal610 611define x86_fp80 @bitcast_x86fp80vec_index0(i160 %x) {612; ANYLE-LABEL: @bitcast_x86fp80vec_index0(613; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i160 [[X:%.*]] to i80614; ANYLE-NEXT:    [[R:%.*]] = bitcast i80 [[TMP1]] to x86_fp80615; ANYLE-NEXT:    ret x86_fp80 [[R]]616;617; ANYBE-LABEL: @bitcast_x86fp80vec_index0(618; ANYBE-NEXT:    [[V:%.*]] = bitcast i160 [[X:%.*]] to <2 x x86_fp80>619; ANYBE-NEXT:    [[R:%.*]] = extractelement <2 x x86_fp80> [[V]], i64 0620; ANYBE-NEXT:    ret x86_fp80 [[R]]621;622  %v = bitcast i160 %x to <2 x x86_fp80>623  %r = extractelement <2 x x86_fp80> %v, i8 0624  ret x86_fp80 %r625}626 627; negative test - input integer should be legal628 629define x86_fp80 @bitcast_x86fp80vec_index1(i160 %x) {630; ANYLE-LABEL: @bitcast_x86fp80vec_index1(631; ANYLE-NEXT:    [[V:%.*]] = bitcast i160 [[X:%.*]] to <2 x x86_fp80>632; ANYLE-NEXT:    [[R:%.*]] = extractelement <2 x x86_fp80> [[V]], i64 1633; ANYLE-NEXT:    ret x86_fp80 [[R]]634;635; ANYBE-LABEL: @bitcast_x86fp80vec_index1(636; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i160 [[X:%.*]] to i80637; ANYBE-NEXT:    [[R:%.*]] = bitcast i80 [[TMP1]] to x86_fp80638; ANYBE-NEXT:    ret x86_fp80 [[R]]639;640  %v = bitcast i160 %x to <2 x x86_fp80>641  %r = extractelement <2 x x86_fp80> %v, i8 1642  ret x86_fp80 %r643}644 645; negative test - input integer should be legal646 647define fp128 @bitcast_fp128vec_index0(i256 %x) {648; ANYLE-LABEL: @bitcast_fp128vec_index0(649; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i256 [[X:%.*]] to i128650; ANYLE-NEXT:    [[R:%.*]] = bitcast i128 [[TMP1]] to fp128651; ANYLE-NEXT:    ret fp128 [[R]]652;653; ANYBE-LABEL: @bitcast_fp128vec_index0(654; ANYBE-NEXT:    [[V:%.*]] = bitcast i256 [[X:%.*]] to <2 x fp128>655; ANYBE-NEXT:    [[R:%.*]] = extractelement <2 x fp128> [[V]], i64 0656; ANYBE-NEXT:    ret fp128 [[R]]657;658  %v = bitcast i256 %x to <2 x fp128>659  %r = extractelement <2 x fp128> %v, i8 0660  ret fp128 %r661}662 663; negative test - input integer should be legal664 665define fp128 @bitcast_fp128vec_index1(i256 %x) {666; ANYLE-LABEL: @bitcast_fp128vec_index1(667; ANYLE-NEXT:    [[V:%.*]] = bitcast i256 [[X:%.*]] to <2 x fp128>668; ANYLE-NEXT:    [[R:%.*]] = extractelement <2 x fp128> [[V]], i64 1669; ANYLE-NEXT:    ret fp128 [[R]]670;671; ANYBE-LABEL: @bitcast_fp128vec_index1(672; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i256 [[X:%.*]] to i128673; ANYBE-NEXT:    [[R:%.*]] = bitcast i128 [[TMP1]] to fp128674; ANYBE-NEXT:    ret fp128 [[R]]675;676  %v = bitcast i256 %x to <2 x fp128>677  %r = extractelement <2 x fp128> %v, i8 1678  ret fp128 %r679}680 681; negative test - input integer should be legal682 683define ppc_fp128 @bitcast_ppcfp128vec_index0(i256 %x) {684; ANYLE-LABEL: @bitcast_ppcfp128vec_index0(685; ANYLE-NEXT:    [[TMP1:%.*]] = trunc i256 [[X:%.*]] to i128686; ANYLE-NEXT:    [[R:%.*]] = bitcast i128 [[TMP1]] to ppc_fp128687; ANYLE-NEXT:    ret ppc_fp128 [[R]]688;689; ANYBE-LABEL: @bitcast_ppcfp128vec_index0(690; ANYBE-NEXT:    [[V:%.*]] = bitcast i256 [[X:%.*]] to <2 x ppc_fp128>691; ANYBE-NEXT:    [[R:%.*]] = extractelement <2 x ppc_fp128> [[V]], i64 0692; ANYBE-NEXT:    ret ppc_fp128 [[R]]693;694  %v = bitcast i256 %x to <2 x ppc_fp128>695  %r = extractelement <2 x ppc_fp128> %v, i8 0696  ret ppc_fp128 %r697}698 699; negative test -input integer should be legal700 701define ppc_fp128 @bitcast_ppcfp128vec_index1(i256 %x) {702; ANYLE-LABEL: @bitcast_ppcfp128vec_index1(703; ANYLE-NEXT:    [[V:%.*]] = bitcast i256 [[X:%.*]] to <2 x ppc_fp128>704; ANYLE-NEXT:    [[R:%.*]] = extractelement <2 x ppc_fp128> [[V]], i64 1705; ANYLE-NEXT:    ret ppc_fp128 [[R]]706;707; ANYBE-LABEL: @bitcast_ppcfp128vec_index1(708; ANYBE-NEXT:    [[TMP1:%.*]] = trunc i256 [[X:%.*]] to i128709; ANYBE-NEXT:    [[R:%.*]] = bitcast i128 [[TMP1]] to ppc_fp128710; ANYBE-NEXT:    ret ppc_fp128 [[R]]711;712  %v = bitcast i256 %x to <2 x ppc_fp128>713  %r = extractelement <2 x ppc_fp128> %v, i8 1714  ret ppc_fp128 %r715}716 717; negative test - input integer should be legal718 719define i8 @bitcast_scalar_index_variable(i32 %x, i64 %y) {720; ANY-LABEL: @bitcast_scalar_index_variable(721; ANY-NEXT:    [[V:%.*]] = bitcast i32 [[X:%.*]] to <4 x i8>722; ANY-NEXT:    [[R:%.*]] = extractelement <4 x i8> [[V]], i64 [[Y:%.*]]723; ANY-NEXT:    ret i8 [[R]]724;725  %v = bitcast i32 %x to <4 x i8>726  %r = extractelement <4 x i8> %v, i64 %y727  ret i8 %r728}729 730; extra use is not ok, even if we don't need a shift731 732define i8 @bitcast_scalar_index0_use(i64 %x) {733; ANY-LABEL: @bitcast_scalar_index0_use(734; ANY-NEXT:    [[V:%.*]] = bitcast i64 [[X:%.*]] to <8 x i8>735; ANY-NEXT:    call void @use(<8 x i8> [[V]])736; ANY-NEXT:    [[R:%.*]] = extractelement <8 x i8> [[V]], i64 0737; ANY-NEXT:    ret i8 [[R]]738;739 740  %v = bitcast i64 %x to <8 x i8>741  call void @use(<8 x i8> %v)742  %r = extractelement <8 x i8> %v, i64 0743  ret i8 %r744}745 746define i1 @bit_extract_cmp(i64 %x) {747; LE64-LABEL: @bit_extract_cmp(748; LE64-NEXT:    [[TMP1:%.*]] = and i64 [[X:%.*]], 9223372032559808512749; LE64-NEXT:    [[R:%.*]] = icmp eq i64 [[TMP1]], 0750; LE64-NEXT:    ret i1 [[R]]751;752; LE128-LABEL: @bit_extract_cmp(753; LE128-NEXT:    [[V:%.*]] = bitcast i64 [[X:%.*]] to <2 x float>754; LE128-NEXT:    [[E:%.*]] = extractelement <2 x float> [[V]], i64 1755; LE128-NEXT:    [[R:%.*]] = fcmp oeq float [[E]], 0.000000e+00756; LE128-NEXT:    ret i1 [[R]]757;758; ANYBE-LABEL: @bit_extract_cmp(759; ANYBE-NEXT:    [[TMP1:%.*]] = and i64 [[X:%.*]], 2147483647760; ANYBE-NEXT:    [[R:%.*]] = icmp eq i64 [[TMP1]], 0761; ANYBE-NEXT:    ret i1 [[R]]762;763  %v = bitcast i64 %x to <2 x float>764  %e = extractelement <2 x float> %v, i8 1765  %r = fcmp oeq float %e, 0.0766  ret i1 %r767}768 769define i32 @extelt_select_const_operand_vector(i1 %c) {770; ANY-LABEL: @extelt_select_const_operand_vector(771; ANY-NEXT:    [[R:%.*]] = select i1 [[C:%.*]], i32 4, i32 7772; ANY-NEXT:    ret i32 [[R]]773;774  %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>775  %r = extractelement <3 x i32> %s, i32 2776  ret i32 %r777}778 779define float @extelt_select_const_operand_vector_float(i1 %c) {780; ANY-LABEL: @extelt_select_const_operand_vector_float(781; ANY-NEXT:    [[R:%.*]] = select i1 [[C:%.*]], float 4.000000e+00, float 7.000000e+00782; ANY-NEXT:    ret float [[R]]783;784  %s = select i1 %c, <3 x float> <float 2.0, float 3.0, float 4.0>, <3 x float> <float 5.0, float 6.0, float 7.0>785  %r = extractelement <3 x float> %s, i32 2786  ret float %r787}788 789define i32 @extelt_vecselect_const_operand_vector(<3 x i1> %c) {790; ANY-LABEL: @extelt_vecselect_const_operand_vector(791; ANY-NEXT:    [[S:%.*]] = select <3 x i1> [[C:%.*]], <3 x i32> <i32 poison, i32 poison, i32 4>, <3 x i32> <i32 poison, i32 poison, i32 7>792; ANY-NEXT:    [[R:%.*]] = extractelement <3 x i32> [[S]], i64 2793; ANY-NEXT:    ret i32 [[R]]794;795  %s = select <3 x i1> %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>796  %r = extractelement <3 x i32> %s, i32 2797  ret i32 %r798}799 800define i32 @extelt_select_const_operand_extractelt_use(i1 %c) {801; ANY-LABEL: @extelt_select_const_operand_extractelt_use(802; ANY-NEXT:    [[E:%.*]] = select i1 [[C:%.*]], i32 4, i32 7803; ANY-NEXT:    [[M:%.*]] = shl nuw nsw i32 [[E]], 1804; ANY-NEXT:    [[M_2:%.*]] = shl nuw nsw i32 [[E]], 2805; ANY-NEXT:    [[R:%.*]] = mul nuw nsw i32 [[M]], [[M_2]]806; ANY-NEXT:    ret i32 [[R]]807;808  %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>809  %e = extractelement <3 x i32> %s, i32 2810  %m = mul i32 %e, 2811  %m.2 = mul i32 %e, 4812  %r = mul i32 %m, %m.2813  ret i32 %r814}815 816define i32 @extelt_select_const_operand_select_use(i1 %c) {817; ANY-LABEL: @extelt_select_const_operand_select_use(818; ANY-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 poison, i32 3, i32 4>, <3 x i32> <i32 poison, i32 6, i32 7>819; ANY-NEXT:    [[E:%.*]] = extractelement <3 x i32> [[S]], i64 2820; ANY-NEXT:    [[E_2:%.*]] = extractelement <3 x i32> [[S]], i64 1821; ANY-NEXT:    [[R:%.*]] = mul nuw nsw i32 [[E]], [[E_2]]822; ANY-NEXT:    ret i32 [[R]]823;824  %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>825  %e = extractelement <3 x i32> %s, i32 2826  %e.2 = extractelement <3 x i32> %s, i32 1827  %r = mul i32 %e, %e.2828  ret i32 %r829}830 831define i32 @extelt_select_const_operand_vector_cond_index(i1 %c) {832; ANY-LABEL: @extelt_select_const_operand_vector_cond_index(833; ANY-NEXT:    [[E:%.*]] = select i1 [[C:%.*]], i32 3, i32 4834; ANY-NEXT:    [[S:%.*]] = select i1 [[C]], <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>835; ANY-NEXT:    [[R:%.*]] = extractelement <3 x i32> [[S]], i32 [[E]]836; ANY-NEXT:    ret i32 [[R]]837;838  %e = select i1 %c, i32 3, i32 4839  %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>840  %r = extractelement <3 x i32> %s, i32 %e841  ret i32 %r842}843 844define i32 @extelt_select_const_operand_vector_var_index(i1 %c, i32 %e) {845; ANY-LABEL: @extelt_select_const_operand_vector_var_index(846; ANY-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>847; ANY-NEXT:    [[R:%.*]] = extractelement <3 x i32> [[S]], i32 [[E:%.*]]848; ANY-NEXT:    ret i32 [[R]]849;850  %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>851  %r = extractelement <3 x i32> %s, i32 %e852  ret i32 %r853}854 855define i32 @extelt_select_var_const_operand_vector(i1 %c, <3 x i32> %v) {856; ANY-LABEL: @extelt_select_var_const_operand_vector(857; ANY-NEXT:    [[TMP1:%.*]] = extractelement <3 x i32> [[V:%.*]], i64 1858; ANY-NEXT:    [[R:%.*]] = select i1 [[C:%.*]], i32 [[TMP1]], i32 6859; ANY-NEXT:    ret i32 [[R]]860;861  %s = select i1 %c, <3 x i32> %v, <3 x i32> <i32 5, i32 6, i32 7>862  %r = extractelement <3 x i32> %s, i32 1863  ret i32 %r864}865 866define i32 @extelt_select_const_var_operand_vector(i1 %c, <3 x i32> %v) {867; ANY-LABEL: @extelt_select_const_var_operand_vector(868; ANY-NEXT:    [[TMP1:%.*]] = extractelement <3 x i32> [[V:%.*]], i64 0869; ANY-NEXT:    [[R:%.*]] = select i1 [[C:%.*]], i32 5, i32 [[TMP1]]870; ANY-NEXT:    ret i32 [[R]]871;872  %s = select i1 %c, <3 x i32> <i32 5, i32 6, i32 7>, <3 x i32> %v873  %r = extractelement <3 x i32> %s, i32 0874  ret i32 %r875}876 877declare void @use_select(<3 x i32>)878 879define i32 @extelt_select_const_var_operands_vector_extra_use(i1 %c, <3 x i32> %x) {880; ANY-LABEL: @extelt_select_const_var_operands_vector_extra_use(881; ANY-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 42, i32 5, i32 4>, <3 x i32> [[X:%.*]]882; ANY-NEXT:    call void @use_select(<3 x i32> [[S]])883; ANY-NEXT:    [[R:%.*]] = extractelement <3 x i32> [[S]], i64 0884; ANY-NEXT:    ret i32 [[R]]885;886  %s = select i1 %c, <3 x i32> <i32 42, i32 5, i32 4>, <3 x i32> %x887  call void @use_select(<3 x i32> %s)888  %r = extractelement <3 x i32> %s, i64 0889  ret i32 %r890}891 892define i32 @extelt_select_const_operands_vector_extra_use_2(i1 %c) {893; ANY-LABEL: @extelt_select_const_operands_vector_extra_use_2(894; ANY-NEXT:    [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 42, i32 5, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>895; ANY-NEXT:    call void @use_select(<3 x i32> [[S]])896; ANY-NEXT:    [[R:%.*]] = extractelement <3 x i32> [[S]], i64 0897; ANY-NEXT:    ret i32 [[R]]898;899  %s = select i1 %c, <3 x i32> <i32 42, i32 5, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>900  call void @use_select(<3 x i32> %s)901  %r = extractelement <3 x i32> %s, i64 0902  ret i32 %r903}904 905define float @crash_4b8320(<2 x float> %i1, float %i12) {906; ANY-LABEL: @crash_4b8320(907; ANY-NEXT:    [[I6:%.*]] = fmul reassoc <2 x float> [[I1:%.*]], <float 0.000000e+00, float poison>908; ANY-NEXT:    [[TMP1:%.*]] = extractelement <2 x float> [[I6]], i64 0909; ANY-NEXT:    [[TMP2:%.*]] = extractelement <2 x float> [[I6]], i64 0910; ANY-NEXT:    [[TMP3:%.*]] = fadd float [[TMP1]], [[TMP2]]911; ANY-NEXT:    [[I29:%.*]] = fadd float [[TMP3]], 0.000000e+00912; ANY-NEXT:    ret float [[I29]]913;914  %i5 = fmul <2 x float> zeroinitializer, %i1915  %i6 = fmul reassoc <2 x float> zeroinitializer, %i5916  %i147 = extractelement <2 x float> %i6, i64 0917  %i15 = extractelement <2 x float> %i6, i64 0918  %i16 = insertelement <4 x float> zeroinitializer, float %i147, i64 0919  %i17 = insertelement <4 x float> %i16, float %i15, i64 1920  %i18 = insertelement <4 x float> %i17, float %i12, i64 2921  %i19 = shufflevector <4 x float> %i18, <4 x float> zeroinitializer, <4 x i32> <i32 1, i32 1, i32 1, i32 1>922  %i23 = fadd <4 x float> %i19, %i18923  %i24 = shufflevector <4 x float> %i18, <4 x float> zeroinitializer, <4 x i32> <i32 3, i32 3, i32 3, i32 3>924  %i26 = fadd <4 x float> %i23, %i24925  %i29 = extractelement <4 x float> %i26, i64 0926  ret float %i29927}928