140 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=x86_64-apple-macosx -mattr=+avx2 -enable-no-signed-zeros-fp-math | FileCheck %s3 4; Check that the ExeDepsFix pass correctly fixes the domain for broadcast instructions.5; <rdar://problem/16354675>6 7define <4 x float> @ExeDepsFix_broadcastss(<4 x float> %arg, <4 x float> %arg2) {8; CHECK-LABEL: ExeDepsFix_broadcastss:9; CHECK: ## %bb.0:10; CHECK-NEXT: vbroadcastss {{.*#+}} xmm2 = [NaN,NaN,NaN,NaN]11; CHECK-NEXT: vandps %xmm2, %xmm0, %xmm012; CHECK-NEXT: vmaxps %xmm1, %xmm0, %xmm013; CHECK-NEXT: retq14 %bitcast = bitcast <4 x float> %arg to <4 x i32>15 %and = and <4 x i32> %bitcast, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>16 %floatcast = bitcast <4 x i32> %and to <4 x float>17 %max_is_x = fcmp oge <4 x float> %floatcast, %arg218 %max = select <4 x i1> %max_is_x, <4 x float> %floatcast, <4 x float> %arg219 ret <4 x float> %max20}21 22define <8 x float> @ExeDepsFix_broadcastss256(<8 x float> %arg, <8 x float> %arg2) {23; CHECK-LABEL: ExeDepsFix_broadcastss256:24; CHECK: ## %bb.0:25; CHECK-NEXT: vbroadcastss {{.*#+}} ymm2 = [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN]26; CHECK-NEXT: vandps %ymm2, %ymm0, %ymm027; CHECK-NEXT: vmaxps %ymm1, %ymm0, %ymm028; CHECK-NEXT: retq29 %bitcast = bitcast <8 x float> %arg to <8 x i32>30 %and = and <8 x i32> %bitcast, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>31 %floatcast = bitcast <8 x i32> %and to <8 x float>32 %max_is_x = fcmp oge <8 x float> %floatcast, %arg233 %max = select <8 x i1> %max_is_x, <8 x float> %floatcast, <8 x float> %arg234 ret <8 x float> %max35}36 37define <4 x float> @ExeDepsFix_broadcastss_inreg(<4 x float> %arg, <4 x float> %arg2, i32 %broadcastvalue) {38; CHECK-LABEL: ExeDepsFix_broadcastss_inreg:39; CHECK: ## %bb.0:40; CHECK-NEXT: vmovd %edi, %xmm241; CHECK-NEXT: vpbroadcastd %xmm2, %xmm242; CHECK-NEXT: vpand %xmm2, %xmm0, %xmm043; CHECK-NEXT: vmaxps %xmm1, %xmm0, %xmm044; CHECK-NEXT: retq45 %bitcast = bitcast <4 x float> %arg to <4 x i32>46 %in = insertelement <4 x i32> undef, i32 %broadcastvalue, i32 047 %mask = shufflevector <4 x i32> %in, <4 x i32> undef, <4 x i32> zeroinitializer48 %and = and <4 x i32> %bitcast, %mask49 %floatcast = bitcast <4 x i32> %and to <4 x float>50 %max_is_x = fcmp oge <4 x float> %floatcast, %arg251 %max = select <4 x i1> %max_is_x, <4 x float> %floatcast, <4 x float> %arg252 ret <4 x float> %max53}54 55define <8 x float> @ExeDepsFix_broadcastss256_inreg(<8 x float> %arg, <8 x float> %arg2, i32 %broadcastvalue) {56; CHECK-LABEL: ExeDepsFix_broadcastss256_inreg:57; CHECK: ## %bb.0:58; CHECK-NEXT: vmovd %edi, %xmm259; CHECK-NEXT: vpbroadcastd %xmm2, %ymm260; CHECK-NEXT: vpand %ymm2, %ymm0, %ymm061; CHECK-NEXT: vmaxps %ymm1, %ymm0, %ymm062; CHECK-NEXT: retq63 %bitcast = bitcast <8 x float> %arg to <8 x i32>64 %in = insertelement <8 x i32> undef, i32 %broadcastvalue, i32 065 %mask = shufflevector <8 x i32> %in, <8 x i32> undef, <8 x i32> zeroinitializer66 %and = and <8 x i32> %bitcast, %mask67 %floatcast = bitcast <8 x i32> %and to <8 x float>68 %max_is_x = fcmp oge <8 x float> %floatcast, %arg269 %max = select <8 x i1> %max_is_x, <8 x float> %floatcast, <8 x float> %arg270 ret <8 x float> %max71}72 73; In that case the broadcast is directly folded into vandpd.74define <2 x double> @ExeDepsFix_broadcastsd(<2 x double> %arg, <2 x double> %arg2) {75; CHECK-LABEL: ExeDepsFix_broadcastsd:76; CHECK: ## %bb.0:77; CHECK-NEXT: vandpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm078; CHECK-NEXT: vmaxpd %xmm1, %xmm0, %xmm079; CHECK-NEXT: retq80 %bitcast = bitcast <2 x double> %arg to <2 x i64>81 %and = and <2 x i64> %bitcast, <i64 2147483647, i64 2147483647>82 %floatcast = bitcast <2 x i64> %and to <2 x double>83 %max_is_x = fcmp oge <2 x double> %floatcast, %arg284 %max = select <2 x i1> %max_is_x, <2 x double> %floatcast, <2 x double> %arg285 ret <2 x double> %max86}87 88define <4 x double> @ExeDepsFix_broadcastsd256(<4 x double> %arg, <4 x double> %arg2) {89; CHECK-LABEL: ExeDepsFix_broadcastsd256:90; CHECK: ## %bb.0:91; CHECK-NEXT: vbroadcastsd {{.*#+}} ymm2 = [2147483647,2147483647,2147483647,2147483647]92; CHECK-NEXT: vandpd %ymm2, %ymm0, %ymm093; CHECK-NEXT: vmaxpd %ymm1, %ymm0, %ymm094; CHECK-NEXT: retq95 %bitcast = bitcast <4 x double> %arg to <4 x i64>96 %and = and <4 x i64> %bitcast, <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>97 %floatcast = bitcast <4 x i64> %and to <4 x double>98 %max_is_x = fcmp oge <4 x double> %floatcast, %arg299 %max = select <4 x i1> %max_is_x, <4 x double> %floatcast, <4 x double> %arg2100 ret <4 x double> %max101}102 103; ExeDepsFix works top down, thus it coalesces vpunpcklqdq domain with104; vpand and there is nothing more you can do to match vmaxpd.105define <2 x double> @ExeDepsFix_broadcastsd_inreg(<2 x double> %arg, <2 x double> %arg2, i64 %broadcastvalue) {106; CHECK-LABEL: ExeDepsFix_broadcastsd_inreg:107; CHECK: ## %bb.0:108; CHECK-NEXT: vmovq %rdi, %xmm2109; CHECK-NEXT: vpbroadcastq %xmm2, %xmm2110; CHECK-NEXT: vpand %xmm2, %xmm0, %xmm0111; CHECK-NEXT: vmaxpd %xmm1, %xmm0, %xmm0112; CHECK-NEXT: retq113 %bitcast = bitcast <2 x double> %arg to <2 x i64>114 %in = insertelement <2 x i64> undef, i64 %broadcastvalue, i32 0115 %mask = shufflevector <2 x i64> %in, <2 x i64> undef, <2 x i32> zeroinitializer116 %and = and <2 x i64> %bitcast, %mask117 %floatcast = bitcast <2 x i64> %and to <2 x double>118 %max_is_x = fcmp oge <2 x double> %floatcast, %arg2119 %max = select <2 x i1> %max_is_x, <2 x double> %floatcast, <2 x double> %arg2120 ret <2 x double> %max121}122 123define <4 x double> @ExeDepsFix_broadcastsd256_inreg(<4 x double> %arg, <4 x double> %arg2, i64 %broadcastvalue) {124; CHECK-LABEL: ExeDepsFix_broadcastsd256_inreg:125; CHECK: ## %bb.0:126; CHECK-NEXT: vmovq %rdi, %xmm2127; CHECK-NEXT: vpbroadcastq %xmm2, %ymm2128; CHECK-NEXT: vpand %ymm2, %ymm0, %ymm0129; CHECK-NEXT: vmaxpd %ymm1, %ymm0, %ymm0130; CHECK-NEXT: retq131 %bitcast = bitcast <4 x double> %arg to <4 x i64>132 %in = insertelement <4 x i64> undef, i64 %broadcastvalue, i32 0133 %mask = shufflevector <4 x i64> %in, <4 x i64> undef, <4 x i32> zeroinitializer134 %and = and <4 x i64> %bitcast, %mask135 %floatcast = bitcast <4 x i64> %and to <4 x double>136 %max_is_x = fcmp oge <4 x double> %floatcast, %arg2137 %max = select <4 x i1> %max_is_x, <4 x double> %floatcast, <4 x double> %arg2138 ret <4 x double> %max139}140