134 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"5target triple = "powerpc64-unknown-linux-gnu"6 7; These tests are extracted from bitcast.ll.8; Verify that they also work correctly on big-endian targets.9 10define float @test2(<2 x float> %A, <2 x i32> %B) {11; CHECK-LABEL: @test2(12; CHECK-NEXT: [[TMP24:%.*]] = extractelement <2 x float> [[A:%.*]], i64 113; CHECK-NEXT: [[BC:%.*]] = bitcast <2 x i32> [[B:%.*]] to <2 x float>14; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x float> [[BC]], i64 115; CHECK-NEXT: [[ADD:%.*]] = fadd float [[TMP24]], [[TMP4]]16; CHECK-NEXT: ret float [[ADD]]17;18 %tmp28 = bitcast <2 x float> %A to i6419 %tmp23 = trunc i64 %tmp28 to i3220 %tmp24 = bitcast i32 %tmp23 to float21 22 %tmp = bitcast <2 x i32> %B to i6423 %tmp2 = trunc i64 %tmp to i3224 %tmp4 = bitcast i32 %tmp2 to float25 26 %add = fadd float %tmp24, %tmp427 ret float %add28}29 30define float @test3(<2 x float> %A, <2 x i64> %B) {31; CHECK-LABEL: @test3(32; CHECK-NEXT: [[TMP24:%.*]] = extractelement <2 x float> [[A:%.*]], i64 033; CHECK-NEXT: [[BC2:%.*]] = bitcast <2 x i64> [[B:%.*]] to <4 x float>34; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x float> [[BC2]], i64 135; CHECK-NEXT: [[ADD:%.*]] = fadd float [[TMP24]], [[TMP4]]36; CHECK-NEXT: ret float [[ADD]]37;38 %tmp28 = bitcast <2 x float> %A to i6439 %tmp29 = lshr i64 %tmp28, 3240 %tmp23 = trunc i64 %tmp29 to i3241 %tmp24 = bitcast i32 %tmp23 to float42 43 %tmp = bitcast <2 x i64> %B to i12844 %tmp1 = lshr i128 %tmp, 6445 %tmp2 = trunc i128 %tmp1 to i3246 %tmp4 = bitcast i32 %tmp2 to float47 48 %add = fadd float %tmp24, %tmp449 ret float %add50}51 52define <2 x i32> @test4(i32 %A, i32 %B){53; CHECK-LABEL: @test4(54; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32> poison, i32 [[B:%.*]], i64 055; CHECK-NEXT: [[TMP43:%.*]] = insertelement <2 x i32> [[TMP1]], i32 [[A:%.*]], i64 156; CHECK-NEXT: ret <2 x i32> [[TMP43]]57;58 %tmp38 = zext i32 %A to i6459 %tmp32 = zext i32 %B to i6460 %tmp33 = shl i64 %tmp32, 3261 %ins35 = or i64 %tmp33, %tmp3862 %tmp43 = bitcast i64 %ins35 to <2 x i32>63 ret <2 x i32> %tmp4364}65 66define <2 x float> @test5(float %A, float %B) {67; CHECK-LABEL: @test5(68; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x float> poison, float [[B:%.*]], i64 069; CHECK-NEXT: [[TMP43:%.*]] = insertelement <2 x float> [[TMP1]], float [[A:%.*]], i64 170; CHECK-NEXT: ret <2 x float> [[TMP43]]71;72 %tmp37 = bitcast float %A to i3273 %tmp38 = zext i32 %tmp37 to i6474 %tmp31 = bitcast float %B to i3275 %tmp32 = zext i32 %tmp31 to i6476 %tmp33 = shl i64 %tmp32, 3277 %ins35 = or i64 %tmp33, %tmp3878 %tmp43 = bitcast i64 %ins35 to <2 x float>79 ret <2 x float> %tmp4380}81 82define <2 x float> @test6(float %A){83; CHECK-LABEL: @test6(84; CHECK-NEXT: [[TMP35:%.*]] = insertelement <2 x float> <float poison, float 4.200000e+01>, float [[A:%.*]], i64 085; CHECK-NEXT: ret <2 x float> [[TMP35]]86;87 %tmp23 = bitcast float %A to i3288 %tmp24 = zext i32 %tmp23 to i6489 %tmp25 = shl i64 %tmp24, 3290 %mask20 = or i64 %tmp25, 110991769691 %tmp35 = bitcast i64 %mask20 to <2 x float>92 ret <2 x float> %tmp3593}94 95; No change. Bitcasts are canonicalized above bitwise logic.96 97define <2 x i32> @xor_bitcast_vec_to_vec(<1 x i64> %a) {98; CHECK-LABEL: @xor_bitcast_vec_to_vec(99; CHECK-NEXT: [[T1:%.*]] = bitcast <1 x i64> [[A:%.*]] to <2 x i32>100; CHECK-NEXT: [[T2:%.*]] = xor <2 x i32> [[T1]], <i32 1, i32 2>101; CHECK-NEXT: ret <2 x i32> [[T2]]102;103 %t1 = bitcast <1 x i64> %a to <2 x i32>104 %t2 = xor <2 x i32> <i32 1, i32 2>, %t1105 ret <2 x i32> %t2106}107 108; No change. Bitcasts are canonicalized above bitwise logic.109 110define i64 @and_bitcast_vec_to_int(<2 x i32> %a) {111; CHECK-LABEL: @and_bitcast_vec_to_int(112; CHECK-NEXT: [[T1:%.*]] = bitcast <2 x i32> [[A:%.*]] to i64113; CHECK-NEXT: [[T2:%.*]] = and i64 [[T1]], 3114; CHECK-NEXT: ret i64 [[T2]]115;116 %t1 = bitcast <2 x i32> %a to i64117 %t2 = and i64 %t1, 3118 ret i64 %t2119}120 121; No change. Bitcasts are canonicalized above bitwise logic.122 123define <2 x i32> @or_bitcast_int_to_vec(i64 %a) {124; CHECK-LABEL: @or_bitcast_int_to_vec(125; CHECK-NEXT: [[T1:%.*]] = bitcast i64 [[A:%.*]] to <2 x i32>126; CHECK-NEXT: [[T2:%.*]] = or <2 x i32> [[T1]], <i32 1, i32 2>127; CHECK-NEXT: ret <2 x i32> [[T2]]128;129 %t1 = bitcast i64 %a to <2 x i32>130 %t2 = or <2 x i32> %t1, <i32 1, i32 2>131 ret <2 x i32> %t2132}133 134