brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.1 KiB · a0894c3 Raw
329 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22; RUN: opt -S -passes=instcombine %s | FileCheck %s3 4define i32 @fneg_fabs_as_int_f32_noimplicitfloat(float %x) noimplicitfloat {5; CHECK-LABEL: define i32 @fneg_fabs_as_int_f32_noimplicitfloat6; CHECK-SAME: (float [[X:%.*]]) #[[ATTR0:[0-9]+]] {7; CHECK-NEXT:    [[BC:%.*]] = bitcast float [[X]] to i328; CHECK-NEXT:    [[OR:%.*]] = or i32 [[BC]], -21474836489; CHECK-NEXT:    ret i32 [[OR]]10;11  %bc = bitcast float %x to i3212  %or = or i32 %bc, -214748364813  ret i32 %or14}15 16define <2 x i32> @fneg_fabs_as_int_v2f32_noimplicitfloat(<2 x float> %x) noimplicitfloat {17; CHECK-LABEL: define <2 x i32> @fneg_fabs_as_int_v2f32_noimplicitfloat18; CHECK-SAME: (<2 x float> [[X:%.*]]) #[[ATTR0]] {19; CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x float> [[X]] to <2 x i32>20; CHECK-NEXT:    [[OR:%.*]] = or <2 x i32> [[BC]], splat (i32 -2147483648)21; CHECK-NEXT:    ret <2 x i32> [[OR]]22;23  %bc = bitcast <2 x float> %x to <2 x i32>24  %or = or <2 x i32> %bc, <i32 -2147483648, i32 -2147483648>25  ret <2 x i32> %or26}27 28define float @fneg_fabs_fabs_as_int_f32_and_or(float %val) {29; CHECK-LABEL: define float @fneg_fabs_fabs_as_int_f32_and_or30; CHECK-SAME: (float [[VAL:%.*]]) {31; CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[VAL]])32; CHECK-NEXT:    [[TMP2:%.*]] = fneg float [[TMP1]]33; CHECK-NEXT:    ret float [[TMP2]]34;35  %bitcast = bitcast float %val to i3236  %and = and i32 %bitcast, 214748364737  %or = or i32 %and, -214748364838  %fneg.fabs = bitcast i32 %or to float39  ret float %fneg.fabs40}41 42define float @fneg_fabs_as_int_f32_castback(float %val) {43; CHECK-LABEL: define float @fneg_fabs_as_int_f32_castback44; CHECK-SAME: (float [[VAL:%.*]]) {45; CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[VAL]])46; CHECK-NEXT:    [[TMP2:%.*]] = fneg float [[TMP1]]47; CHECK-NEXT:    ret float [[TMP2]]48;49  %bitcast = bitcast float %val to i3250  %or = or i32 %bitcast, -214748364851  %fneg = bitcast i32 %or to float52  ret float %fneg53}54 55define float @not_fneg_fabs_as_int_f32_castback_wrongconst(float %val) {56; CHECK-LABEL: define float @not_fneg_fabs_as_int_f32_castback_wrongconst57; CHECK-SAME: (float [[VAL:%.*]]) {58; CHECK-NEXT:    [[BITCAST:%.*]] = bitcast float [[VAL]] to i3259; CHECK-NEXT:    [[OR:%.*]] = or i32 [[BITCAST]], -214748364760; CHECK-NEXT:    [[FNEG:%.*]] = bitcast i32 [[OR]] to float61; CHECK-NEXT:    ret float [[FNEG]]62;63  %bitcast = bitcast float %val to i3264  %or = or i32 %bitcast, -214748364765  %fneg = bitcast i32 %or to float66  ret float %fneg67}68 69define float @fneg_fabs_as_int_f32_castback_multi_use(float %val, ptr %ptr) {70; CHECK-LABEL: define float @fneg_fabs_as_int_f32_castback_multi_use71; CHECK-SAME: (float [[VAL:%.*]], ptr [[PTR:%.*]]) {72; CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[VAL]])73; CHECK-NEXT:    [[TMP2:%.*]] = fneg float [[TMP1]]74; CHECK-NEXT:    store float [[TMP2]], ptr [[PTR]], align 475; CHECK-NEXT:    ret float [[TMP2]]76;77  %bitcast = bitcast float %val to i3278  %or = or i32 %bitcast, -214748364879  store i32 %or, ptr %ptr80  %fneg = bitcast i32 %or to float81  ret float %fneg82}83 84define i64 @fneg_fabs_as_int_f64(double %x) {85; CHECK-LABEL: define i64 @fneg_fabs_as_int_f6486; CHECK-SAME: (double [[X:%.*]]) {87; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.fabs.f64(double [[X]])88; CHECK-NEXT:    [[TMP2:%.*]] = fneg double [[TMP1]]89; CHECK-NEXT:    [[OR:%.*]] = bitcast double [[TMP2]] to i6490; CHECK-NEXT:    ret i64 [[OR]]91;92  %bc = bitcast double %x to i6493  %or = or i64 %bc, -922337203685477580894  ret i64 %or95}96 97define <2 x i64> @fneg_fabs_as_int_v2f64(<2 x double> %x) {98; CHECK-LABEL: define <2 x i64> @fneg_fabs_as_int_v2f6499; CHECK-SAME: (<2 x double> [[X:%.*]]) {100; CHECK-NEXT:    [[TMP1:%.*]] = call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X]])101; CHECK-NEXT:    [[TMP2:%.*]] = fneg <2 x double> [[TMP1]]102; CHECK-NEXT:    [[OR:%.*]] = bitcast <2 x double> [[TMP2]] to <2 x i64>103; CHECK-NEXT:    ret <2 x i64> [[OR]]104;105  %bc = bitcast <2 x double> %x to <2 x i64>106  %or = or <2 x i64> %bc, <i64 -9223372036854775808, i64 -9223372036854775808>107  ret <2 x i64> %or108}109 110define i64 @fneg_fabs_as_int_f64_swap(double %x) {111; CHECK-LABEL: define i64 @fneg_fabs_as_int_f64_swap112; CHECK-SAME: (double [[X:%.*]]) {113; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.fabs.f64(double [[X]])114; CHECK-NEXT:    [[TMP2:%.*]] = fneg double [[TMP1]]115; CHECK-NEXT:    [[OR:%.*]] = bitcast double [[TMP2]] to i64116; CHECK-NEXT:    ret i64 [[OR]]117;118  %bc = bitcast double %x to i64119  %or = or i64 -9223372036854775808, %bc120  ret i64 %or121}122 123define i32 @fneg_fabs_as_int_f32(float %x) {124; CHECK-LABEL: define i32 @fneg_fabs_as_int_f32125; CHECK-SAME: (float [[X:%.*]]) {126; CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[X]])127; CHECK-NEXT:    [[TMP2:%.*]] = fneg float [[TMP1]]128; CHECK-NEXT:    [[OR:%.*]] = bitcast float [[TMP2]] to i32129; CHECK-NEXT:    ret i32 [[OR]]130;131  %bc = bitcast float %x to i32132  %or = or i32 %bc, -2147483648133  ret i32 %or134}135 136define <2 x i32> @fneg_fabs_as_int_v2f32(<2 x float> %x) {137; CHECK-LABEL: define <2 x i32> @fneg_fabs_as_int_v2f32138; CHECK-SAME: (<2 x float> [[X:%.*]]) {139; CHECK-NEXT:    [[TMP1:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[X]])140; CHECK-NEXT:    [[TMP2:%.*]] = fneg <2 x float> [[TMP1]]141; CHECK-NEXT:    [[OR:%.*]] = bitcast <2 x float> [[TMP2]] to <2 x i32>142; CHECK-NEXT:    ret <2 x i32> [[OR]]143;144  %bc = bitcast <2 x float> %x to <2 x i32>145  %or = or <2 x i32> %bc, <i32 -2147483648, i32 -2147483648>146  ret <2 x i32> %or147}148 149define <2 x i32> @not_fneg_fabs_as_int_v2f32_nonsplat(<2 x float> %x) {150; CHECK-LABEL: define <2 x i32> @not_fneg_fabs_as_int_v2f32_nonsplat151; CHECK-SAME: (<2 x float> [[X:%.*]]) {152; CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x float> [[X]] to <2 x i32>153; CHECK-NEXT:    [[OR:%.*]] = or <2 x i32> [[BC]], <i32 -2147483648, i32 -2147483647>154; CHECK-NEXT:    ret <2 x i32> [[OR]]155;156  %bc = bitcast <2 x float> %x to <2 x i32>157  %or = or <2 x i32> %bc, <i32 -2147483648, i32 -2147483647>158  ret <2 x i32> %or159}160 161define <3 x i32> @fneg_fabs_as_int_v3f32_poison(<3 x float> %x) {162; CHECK-LABEL: define <3 x i32> @fneg_fabs_as_int_v3f32_poison163; CHECK-SAME: (<3 x float> [[X:%.*]]) {164; CHECK-NEXT:    [[TMP1:%.*]] = call <3 x float> @llvm.fabs.v3f32(<3 x float> [[X]])165; CHECK-NEXT:    [[TMP2:%.*]] = fneg <3 x float> [[TMP1]]166; CHECK-NEXT:    [[OR:%.*]] = bitcast <3 x float> [[TMP2]] to <3 x i32>167; CHECK-NEXT:    ret <3 x i32> [[OR]]168;169  %bc = bitcast <3 x float> %x to <3 x i32>170  %or = or <3 x i32> %bc, <i32 -2147483648, i32 poison, i32 -2147483648>171  ret <3 x i32> %or172}173 174; Make sure that only a bitcast is transformed.175define i64 @fneg_fabs_as_int_f64_not_bitcast(double %x) {176; CHECK-LABEL: define i64 @fneg_fabs_as_int_f64_not_bitcast177; CHECK-SAME: (double [[X:%.*]]) {178; CHECK-NEXT:    [[BC:%.*]] = fptoui double [[X]] to i64179; CHECK-NEXT:    [[OR:%.*]] = or i64 [[BC]], -9223372036854775808180; CHECK-NEXT:    ret i64 [[OR]]181;182  %bc = fptoui double %x to i64183  %or = or i64 %bc, -9223372036854775808184  ret i64 %or185}186 187define float @not_fneg_fabs_as_int_f32_bitcast_from_v2f16(<2 x half> %val) {188; CHECK-LABEL: define float @not_fneg_fabs_as_int_f32_bitcast_from_v2f16189; CHECK-SAME: (<2 x half> [[VAL:%.*]]) {190; CHECK-NEXT:    [[BITCAST:%.*]] = bitcast <2 x half> [[VAL]] to i32191; CHECK-NEXT:    [[OR:%.*]] = or i32 [[BITCAST]], -2147483648192; CHECK-NEXT:    [[FNEG:%.*]] = bitcast i32 [[OR]] to float193; CHECK-NEXT:    ret float [[FNEG]]194;195  %bitcast = bitcast <2 x half> %val to i32196  %or = or i32 %bitcast, -2147483648197  %fneg = bitcast i32 %or to float198  ret float %fneg199}200 201define float @not_fneg_fabs_as_int_f32_bitcast_from_v2i16(<2 x i16> %val) {202; CHECK-LABEL: define float @not_fneg_fabs_as_int_f32_bitcast_from_v2i16203; CHECK-SAME: (<2 x i16> [[VAL:%.*]]) {204; CHECK-NEXT:    [[BITCAST:%.*]] = bitcast <2 x i16> [[VAL]] to i32205; CHECK-NEXT:    [[OR:%.*]] = or i32 [[BITCAST]], -2147483648206; CHECK-NEXT:    [[FNEG:%.*]] = bitcast i32 [[OR]] to float207; CHECK-NEXT:    ret float [[FNEG]]208;209  %bitcast = bitcast <2 x i16> %val to i32210  %or = or i32 %bitcast, -2147483648211  %fneg = bitcast i32 %or to float212  ret float %fneg213}214 215define i128 @fneg_fabs_as_int_fp128_f64_mask(fp128 %x) {216; CHECK-LABEL: define i128 @fneg_fabs_as_int_fp128_f64_mask217; CHECK-SAME: (fp128 [[X:%.*]]) {218; CHECK-NEXT:    [[BC:%.*]] = bitcast fp128 [[X]] to i128219; CHECK-NEXT:    [[OR:%.*]] = or i128 [[BC]], -9223372036854775808220; CHECK-NEXT:    ret i128 [[OR]]221;222  %bc = bitcast fp128 %x to i128223  %or = or i128 %bc, -9223372036854775808224  ret i128 %or225}226 227define i128 @fneg_fabs_as_int_fp128_f128_mask(fp128 %x) {228; CHECK-LABEL: define i128 @fneg_fabs_as_int_fp128_f128_mask229; CHECK-SAME: (fp128 [[X:%.*]]) {230; CHECK-NEXT:    [[TMP1:%.*]] = call fp128 @llvm.fabs.f128(fp128 [[X]])231; CHECK-NEXT:    [[TMP2:%.*]] = fneg fp128 [[TMP1]]232; CHECK-NEXT:    [[OR:%.*]] = bitcast fp128 [[TMP2]] to i128233; CHECK-NEXT:    ret i128 [[OR]]234;235  %bc = bitcast fp128 %x to i128236  %or = or i128 %bc, -170141183460469231731687303715884105728237  ret i128 %or238}239 240define i16 @fneg_fabs_as_int_f16(half %x) {241; CHECK-LABEL: define i16 @fneg_fabs_as_int_f16242; CHECK-SAME: (half [[X:%.*]]) {243; CHECK-NEXT:    [[TMP1:%.*]] = call half @llvm.fabs.f16(half [[X]])244; CHECK-NEXT:    [[TMP2:%.*]] = fneg half [[TMP1]]245; CHECK-NEXT:    [[OR:%.*]] = bitcast half [[TMP2]] to i16246; CHECK-NEXT:    ret i16 [[OR]]247;248  %bc = bitcast half %x to i16249  %or = or i16 %bc, -32768250  ret i16 %or251}252 253define <2 x i16> @fneg_fabs_as_int_v2f16(<2 x half> %x) {254; CHECK-LABEL: define <2 x i16> @fneg_fabs_as_int_v2f16255; CHECK-SAME: (<2 x half> [[X:%.*]]) {256; CHECK-NEXT:    [[TMP1:%.*]] = call <2 x half> @llvm.fabs.v2f16(<2 x half> [[X]])257; CHECK-NEXT:    [[TMP2:%.*]] = fneg <2 x half> [[TMP1]]258; CHECK-NEXT:    [[OR:%.*]] = bitcast <2 x half> [[TMP2]] to <2 x i16>259; CHECK-NEXT:    ret <2 x i16> [[OR]]260;261  %bc = bitcast <2 x half> %x to <2 x i16>262  %or = or <2 x i16> %bc, <i16 -32768, i16 -32768>263  ret <2 x i16> %or264}265 266define i16 @fneg_fabs_as_int_bf16(bfloat %x) {267; CHECK-LABEL: define i16 @fneg_fabs_as_int_bf16268; CHECK-SAME: (bfloat [[X:%.*]]) {269; CHECK-NEXT:    [[TMP1:%.*]] = call bfloat @llvm.fabs.bf16(bfloat [[X]])270; CHECK-NEXT:    [[TMP2:%.*]] = fneg bfloat [[TMP1]]271; CHECK-NEXT:    [[OR:%.*]] = bitcast bfloat [[TMP2]] to i16272; CHECK-NEXT:    ret i16 [[OR]]273;274  %bc = bitcast bfloat %x to i16275  %or = or i16 %bc, -32768276  ret i16 %or277}278 279define <2 x i16> @fneg_fabs_as_int_v2bf16(<2 x bfloat> %x) {280; CHECK-LABEL: define <2 x i16> @fneg_fabs_as_int_v2bf16281; CHECK-SAME: (<2 x bfloat> [[X:%.*]]) {282; CHECK-NEXT:    [[TMP1:%.*]] = call <2 x bfloat> @llvm.fabs.v2bf16(<2 x bfloat> [[X]])283; CHECK-NEXT:    [[TMP2:%.*]] = fneg <2 x bfloat> [[TMP1]]284; CHECK-NEXT:    [[OR:%.*]] = bitcast <2 x bfloat> [[TMP2]] to <2 x i16>285; CHECK-NEXT:    ret <2 x i16> [[OR]]286;287  %bc = bitcast <2 x bfloat> %x to <2 x i16>288  %or = or <2 x i16> %bc, <i16 -32768, i16 -32768>289  ret <2 x i16> %or290}291 292define i80 @fneg_fabs_as_int_x86_fp80_f64_mask(x86_fp80 %x) {293; CHECK-LABEL: define i80 @fneg_fabs_as_int_x86_fp80_f64_mask294; CHECK-SAME: (x86_fp80 [[X:%.*]]) {295; CHECK-NEXT:    [[TMP1:%.*]] = call x86_fp80 @llvm.fabs.f80(x86_fp80 [[X]])296; CHECK-NEXT:    [[TMP2:%.*]] = fneg x86_fp80 [[TMP1]]297; CHECK-NEXT:    [[OR:%.*]] = bitcast x86_fp80 [[TMP2]] to i80298; CHECK-NEXT:    ret i80 [[OR]]299;300  %bc = bitcast x86_fp80 %x to i80301  %or = or i80 %bc, -604462909807314587353088302  ret i80 %or303}304 305define i128 @fneg_fabs_as_int_ppc_fp128_f64_mask(ppc_fp128 %x) {306; CHECK-LABEL: define i128 @fneg_fabs_as_int_ppc_fp128_f64_mask307; CHECK-SAME: (ppc_fp128 [[X:%.*]]) {308; CHECK-NEXT:    [[BC:%.*]] = bitcast ppc_fp128 [[X]] to i128309; CHECK-NEXT:    [[OR:%.*]] = or i128 [[BC]], -9223372036854775808310; CHECK-NEXT:    ret i128 [[OR]]311;312  %bc = bitcast ppc_fp128 %x to i128313  %or = or i128 %bc, -9223372036854775808314  ret i128 %or315}316 317define i128 @fneg_fabs_as_int_ppc_fp128_f128_mask(ppc_fp128 %x) {318; CHECK-LABEL: define i128 @fneg_fabs_as_int_ppc_fp128_f128_mask319; CHECK-SAME: (ppc_fp128 [[X:%.*]]) {320; CHECK-NEXT:    [[TMP1:%.*]] = call ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 [[X]])321; CHECK-NEXT:    [[TMP2:%.*]] = fneg ppc_fp128 [[TMP1]]322; CHECK-NEXT:    [[OR:%.*]] = bitcast ppc_fp128 [[TMP2]] to i128323; CHECK-NEXT:    ret i128 [[OR]]324;325  %bc = bitcast ppc_fp128 %x to i128326  %or = or i128 %bc, -170141183460469231731687303715884105728327  ret i128 %or328}329