[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Thu May 15 13:52:13 PDT 2025
================
@@ -0,0 +1,63 @@
+# RUN: llc -verify-machineinstrs -O0 -mtriple spirv-unknown-unknown -run-pass=spirv-prelegalizer-combiner %s -o - | FileCheck %s
+# REQUIRES: asserts
+---
+name: faceforward_instcombine_float
+tracksRegLiveness: true
+legalized: true
+body: |
+ bb.1.entry:
+ ; CHECK-LABEL: name: faceforward_instcombine_float
+ ; CHECK-NOT: %9:_(s32) = G_FCONSTANT float 0.000000e+00
+ ; CHECK-NOT: %8:_(s32) = G_FMUL %1:fid, %2:fid
+ ; CHECK-NOT: %10:_(s1) = G_FCMP floatpred(olt), %8:_(s32), %9:_
+ ; CHECK-NOT: %11:_(s32) = G_FNEG %0:fid
+ ; CHECK-NOT: %12:id(s32) = G_SELECT %10:_(s1), %0:fid, %11:_
+ ; CHECK: %10:id(s32) = G_INTRINSIC intrinsic(@llvm.spv.faceforward), %2(s32), %3(s32), %4(s32)
----------------
farzonl wrote:
In this case the register count would be different than the length to distance case so we can't just `; CHECK: %10:id(s32) = ` we also need to check that OpReturnValue returns %10 like so: `; CHECK: OpReturnValue %10:id(s32)`
https://github.com/llvm/llvm-project/pull/139959
More information about the cfe-commits
mailing list