|
| 1 | +# RUN: llc -verify-machineinstrs -O0 -mtriple spirv-vulkan1.3-unknown -run-pass=spirv-prelegalizer-combiner %s -o - | FileCheck %s |
| 2 | +# REQUIRES: asserts |
| 3 | +--- |
| 4 | +name: faceforward_instcombine_float |
| 5 | +tracksRegLiveness: true |
| 6 | +legalized: true |
| 7 | +body: | |
| 8 | + bb.1.entry: |
| 9 | + ; CHECK-LABEL: name: faceforward_instcombine_float |
| 10 | + ; CHECK-NOT: %9:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 11 | + ; CHECK-NOT: %8:_(s32) = G_FMUL %1:fid, %2:fid |
| 12 | + ; CHECK-NOT: %10:_(s1) = G_FCMP floatpred(olt), %8:_(s32), %9:_ |
| 13 | + ; CHECK-NOT: %11:_(s32) = G_FNEG %0:fid |
| 14 | + ; CHECK-NOT: %12:id(s32) = G_SELECT %10:_(s1), %0:fid, %11:_ |
| 15 | + ; CHECK: %10:id(s32) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %2(s32), %3(s32), %4(s32) |
| 16 | + ; CHECK: OpReturnValue %10(s32) |
| 17 | + %3:type(s64) = OpTypeFloat 32 |
| 18 | + %5:type(s64) = OpTypeFunction %3:type(s64), %3:type(s64), %3:type(s64), %3:type(s64) |
| 19 | + OpName %0:fid(s32), 97 |
| 20 | + OpName %1:fid(s32), 98 |
| 21 | + OpName %2:fid(s32), 99 |
| 22 | + %4:iid(s64) = OpFunction %3:type(s64), 0, %5:type(s64) |
| 23 | + %0:fid(s32) = OpFunctionParameter %3:type(s64) |
| 24 | + %1:fid(s32) = OpFunctionParameter %3:type(s64) |
| 25 | + %2:fid(s32) = OpFunctionParameter %3:type(s64) |
| 26 | + OpName %4:iid(s64), 1701011814, 2003988326, 1600418401, 1953721961, 1651339107, 1600482921, 1634692198, 116 |
| 27 | + %9:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 28 | + %8:_(s32) = G_FMUL %1:fid, %2:fid |
| 29 | + %10:_(s1) = G_FCMP floatpred(olt), %8:_(s32), %9:_ |
| 30 | + %11:_(s32) = G_FNEG %0:fid |
| 31 | + %12:id(s32) = G_SELECT %10:_(s1), %0:fid, %11:_ |
| 32 | + OpReturnValue %12:id(s32) |
| 33 | +--- |
| 34 | +name: faceforward_instcombine_float4 |
| 35 | +tracksRegLiveness: true |
| 36 | +legalized: true |
| 37 | +body: | |
| 38 | + bb.1.entry: |
| 39 | + ; CHECK-LABEL: name: faceforward_instcombine_float4 |
| 40 | + ; CHECK-NOT: %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 41 | + ; CHECK-NOT: %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 42 | + ; CHECK-NOT: %11:_(s1) = G_FCMP floatpred(olt), %9:_(s32), %10:_ |
| 43 | + ; CHECK-NOT: %12:_(<4 x s32>) = G_FNEG %0:vfid |
| 44 | + ; CHECK-NOT: %13:id(<4 x s32>) = G_SELECT %11:_(s1), %0:vfid, %12:_ |
| 45 | + ; CHECK: %11:id(<4 x s32>) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %3(<4 x s32>), %4(<4 x s32>), %5(<4 x s32>) |
| 46 | + ; CHECK: OpReturnValue %11(<4 x s32>) |
| 47 | + %4:type(s64) = OpTypeVector %3:type(s64), 4 |
| 48 | + %6:type(s64) = OpTypeFunction %4:type(s64), %4:type(s64), %4:type(s64), %4:type(s64) |
| 49 | + %3:type(s64) = OpTypeFloat 32 |
| 50 | + OpName %0:vfid(<4 x s32>), 97 |
| 51 | + OpName %1:vfid(<4 x s32>), 98 |
| 52 | + OpName %2:vfid(<4 x s32>), 99 |
| 53 | + %5:iid(s64) = OpFunction %4:type(s64), 0, %6:type(s64) |
| 54 | + %0:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 55 | + %1:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 56 | + %2:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 57 | + OpName %5:iid(s64), 1701011814, 2003988326, 1600418401, 1953721961, 1651339107, 1600482921, 1634692198, 13428 |
| 58 | + %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 59 | + %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 60 | + %11:_(s1) = G_FCMP floatpred(olt), %9:_(s32), %10:_ |
| 61 | + %12:_(<4 x s32>) = G_FNEG %0:vfid |
| 62 | + %13:id(<4 x s32>) = G_SELECT %11:_(s1), %0:vfid, %12:_ |
| 63 | + OpReturnValue %13:id(<4 x s32>) |
| 64 | +--- |
| 65 | +name: faceforward_instcombine_float_constants |
| 66 | +tracksRegLiveness: true |
| 67 | +legalized: true |
| 68 | +body: | |
| 69 | + bb.1.entry: |
| 70 | + ; CHECK-LABEL: name: faceforward_instcombine_float_constants |
| 71 | + ; CHECK-NOT: %9:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 72 | + ; CHECK-NOT: %13:_(s32) = G_FCONSTANT float -1.000000e+00 |
| 73 | + ; CHECK-NOT: %8:_(s32) = G_FMUL %1:fid, %2:fid |
| 74 | + ; CHECK-NOT: %10:_(s1) = G_FCMP floatpred(olt), %8:_(s32), %9:_ |
| 75 | + ; CHECK-NOT: %11:id(s32) = G_SELECT %10:_(s1), %12:_, %13:_ |
| 76 | + ; CHECK: %7:_(s32) = G_FCONSTANT float 1.000000e+00 |
| 77 | + ; CHECK: %11:id(s32) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %7(s32), %3(s32), %4(s32) |
| 78 | + ; CHECK: OpReturnValue %11(s32) |
| 79 | + %3:type(s64) = OpTypeFloat 32 |
| 80 | + %5:type(s64) = OpTypeFunction %3:type(s64), %3:type(s64), %3:type(s64), %3:type(s64) |
| 81 | + OpName %0:fid(s32), 97 |
| 82 | + OpName %1:fid(s32), 98 |
| 83 | + OpName %2:fid(s32), 99 |
| 84 | + %4:iid(s64) = OpFunction %3:type(s64), 0, %5:type(s64) |
| 85 | + %0:fid(s32) = OpFunctionParameter %3:type(s64) |
| 86 | + %1:fid(s32) = OpFunctionParameter %3:type(s64) |
| 87 | + %2:fid(s32) = OpFunctionParameter %3:type(s64) |
| 88 | + OpName %4:iid(s64), 1701011814, 2003988326, 1600418401, 1953721961, 1651339107, 1600482921, 1634692198, 1868783476, 1635021678, 7566446 |
| 89 | + %9:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 90 | + %12:_(s32) = G_FCONSTANT float 1.000000e+00 |
| 91 | + %13:_(s32) = G_FCONSTANT float -1.000000e+00 |
| 92 | + %8:_(s32) = G_FMUL %1:fid, %2:fid |
| 93 | + %10:_(s1) = G_FCMP floatpred(olt), %8:_(s32), %9:_ |
| 94 | + %11:id(s32) = G_SELECT %10:_(s1), %12:_, %13:_ |
| 95 | + OpReturnValue %11:id(s32) |
| 96 | +--- |
| 97 | +name: faceforward_instcombine_float4_constants |
| 98 | +tracksRegLiveness: true |
| 99 | +legalized: true |
| 100 | +body: | |
| 101 | + bb.1.entry: |
| 102 | + ; CHECK-LABEL: name: faceforward_instcombine_float4_constants |
| 103 | + ; CHECK-NOT: %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 104 | + ; CHECK-NOT: %16:_(s32) = G_FCONSTANT float -1.000000e+00 |
| 105 | + ; CHECK-NOT: %15:_(<4 x s32>) = G_BUILD_VECTOR %16:_(s32), %16:_(s32), %16:_(s32), %16:_(s32) |
| 106 | + ; CHECK-NOT: %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 107 | + ; CHECK-NOT: %11:_(s1) = G_FCMP floatpred(olt), %9:_(s32), %10:_ |
| 108 | + ; CHECK-NOT: %12:id(<4 x s32>) = G_SELECT %11:_(s1), %13:_, %15:_ |
| 109 | + ; CHECK: %8:_(s32) = G_FCONSTANT float 1.000000e+00 |
| 110 | + ; CHECK: %9:_(<4 x s32>) = G_BUILD_VECTOR %8(s32), %8(s32), %8(s32), %8(s32) |
| 111 | + ; CHECK: %14:id(<4 x s32>) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %9(<4 x s32>), %4(<4 x s32>), %5(<4 x s32>) |
| 112 | + ; CHECK: OpReturnValue %14(<4 x s32>) |
| 113 | + %4:type(s64) = OpTypeVector %3:type(s64), 4 |
| 114 | + %6:type(s64) = OpTypeFunction %4:type(s64), %4:type(s64), %4:type(s64), %4:type(s64) |
| 115 | + %3:type(s64) = OpTypeFloat 32 |
| 116 | + OpName %0:vfid(<4 x s32>), 97 |
| 117 | + OpName %1:vfid(<4 x s32>), 98 |
| 118 | + OpName %2:vfid(<4 x s32>), 99 |
| 119 | + %5:iid(s64) = OpFunction %4:type(s64), 0, %6:type(s64) |
| 120 | + %0:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 121 | + %1:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 122 | + %2:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 123 | + OpName %5:iid(s64), 1701011814, 2003988326, 1600418401, 1953721961, 1651339107, 1600482921, 1634692198, 1667183732, 1953721967, 1937010273, 0 |
| 124 | + %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 125 | + %14:_(s32) = G_FCONSTANT float 1.000000e+00 |
| 126 | + %13:_(<4 x s32>) = G_BUILD_VECTOR %14:_(s32), %14:_(s32), %14:_(s32), %14:_(s32) |
| 127 | + %16:_(s32) = G_FCONSTANT float -1.000000e+00 |
| 128 | + %15:_(<4 x s32>) = G_BUILD_VECTOR %16:_(s32), %16:_(s32), %16:_(s32), %16:_(s32) |
| 129 | + %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 130 | + %11:_(s1) = G_FCMP floatpred(olt), %9:_(s32), %10:_ |
| 131 | + %12:id(<4 x s32>) = G_SELECT %11:_(s1), %13:_, %15:_ |
| 132 | + OpReturnValue %12:id(<4 x s32>) |
| 133 | +--- |
| 134 | +name: faceforward_instcombine_float4_false_fmul |
| 135 | +tracksRegLiveness: true |
| 136 | +legalized: true |
| 137 | +body: | |
| 138 | + bb.1.entry: |
| 139 | + ; CHECK-LABEL: name: faceforward_instcombine_float4_false_fmul |
| 140 | + ; CHECK-NOT: %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 141 | + ; CHECK-NOT: %13:_(s32) = G_FCONSTANT float -1.000000e+00 |
| 142 | + ; CHECK-NOT: %12:_(<4 x s32>) = G_BUILD_VECTOR %13:_(s32), %13:_(s32), %13:_(s32), %13:_(s32) |
| 143 | + ; CHECK-NOT: %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 144 | + ; CHECK-NOT: %11:_(s1) = G_FCMP floatpred(olt), %9:_(s32), %10:_ |
| 145 | + ; CHECK-NOT: %14:_(<4 x s32>) = G_FMUL %0:vfid, %12:_ |
| 146 | + ; CHECK-NOT: %15:id(<4 x s32>) = G_SELECT %11:_(s1), %0:vfid, %14:_ |
| 147 | + ; CHECK: %13:id(<4 x s32>) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %3(<4 x s32>), %4(<4 x s32>), %5(<4 x s32>) |
| 148 | + ; CHECK: OpReturnValue %13(<4 x s32>) |
| 149 | + %4:type(s64) = OpTypeVector %3:type(s64), 4 |
| 150 | + %6:type(s64) = OpTypeFunction %4:type(s64), %4:type(s64), %4:type(s64), %4:type(s64) |
| 151 | + %3:type(s64) = OpTypeFloat 32 |
| 152 | + OpName %0:vfid(<4 x s32>), 97 |
| 153 | + OpName %1:vfid(<4 x s32>), 98 |
| 154 | + OpName %2:vfid(<4 x s32>), 99 |
| 155 | + %5:iid(s64) = OpFunction %4:type(s64), 0, %6:type(s64) |
| 156 | + %0:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 157 | + %1:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 158 | + %2:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 159 | + OpName %5:iid(s64), 1701011814, 2003988326, 1600418401, 1953721961, 1651339107, 1600482921, 1634692198, 1717515380, 1702063201, 1970103903, 108 |
| 160 | + %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 161 | + %13:_(s32) = G_FCONSTANT float -1.000000e+00 |
| 162 | + %12:_(<4 x s32>) = G_BUILD_VECTOR %13:_(s32), %13:_(s32), %13:_(s32), %13:_(s32) |
| 163 | + %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 164 | + %11:_(s1) = G_FCMP floatpred(olt), %9:_(s32), %10:_ |
| 165 | + %14:_(<4 x s32>) = G_FMUL %0:vfid, %12:_ |
| 166 | + %15:id(<4 x s32>) = G_SELECT %11:_(s1), %0:vfid, %14:_ |
| 167 | + OpReturnValue %15:id(<4 x s32>) |
| 168 | +--- |
| 169 | +name: faceforward_instcombine_float4_ogt |
| 170 | +tracksRegLiveness: true |
| 171 | +legalized: true |
| 172 | +body: | |
| 173 | + bb.1.entry: |
| 174 | + ; CHECK-LABEL: name: faceforward_instcombine_float4 |
| 175 | + ; CHECK-NOT: %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 176 | + ; CHECK-NOT: %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 177 | + ; CHECK-NOT: %11:_(s1) = G_FCMP floatpred(ogt), %10:_(s32), %9:_ |
| 178 | + ; CHECK-NOT: %12:_(<4 x s32>) = G_FNEG %0:vfid |
| 179 | + ; CHECK-NOT: %13:id(<4 x s32>) = G_SELECT %11:_(s1), %12:_, %0:vfid |
| 180 | + ; CHECK: %11:id(<4 x s32>) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %3(<4 x s32>), %4(<4 x s32>), %5(<4 x s32>) |
| 181 | + ; CHECK: OpReturnValue %11(<4 x s32>) |
| 182 | + %4:type(s64) = OpTypeVector %3:type(s64), 4 |
| 183 | + %6:type(s64) = OpTypeFunction %4:type(s64), %4:type(s64), %4:type(s64), %4:type(s64) |
| 184 | + %3:type(s64) = OpTypeFloat 32 |
| 185 | + OpName %0:vfid(<4 x s32>), 97 |
| 186 | + OpName %1:vfid(<4 x s32>), 98 |
| 187 | + OpName %2:vfid(<4 x s32>), 99 |
| 188 | + %5:iid(s64) = OpFunction %4:type(s64), 0, %6:type(s64) |
| 189 | + %0:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 190 | + %1:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 191 | + %2:vfid(<4 x s32>) = OpFunctionParameter %4:type(s64) |
| 192 | + OpName %5:iid(s64), 1701011814, 2003988326, 1600418401, 1953721961, 1651339107, 1600482921, 1634692198, 1868510324, 29799 |
| 193 | + %10:_(s32) = G_FCONSTANT float 0.000000e+00 |
| 194 | + %9:_(s32) = G_INTRINSIC intrinsic(@llvm.spv.fdot), %1:vfid(<4 x s32>), %2:vfid(<4 x s32>) |
| 195 | + %11:_(s1) = G_FCMP floatpred(ogt), %10:_(s32), %9:_ |
| 196 | + %12:_(<4 x s32>) = G_FNEG %0:vfid |
| 197 | + %13:id(<4 x s32>) = G_SELECT %11:_(s1), %12:_, %0:vfid |
| 198 | + OpReturnValue %13:id(<4 x s32>) |
| 199 | +
|
0 commit comments