[llvm] Add PreLegalizer pattern matching for degrees GL extension (PR #216506)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 02:03:25 PDT 2026


================
@@ -185,6 +185,60 @@ void SPIRVCombinerHelper::applySPIRVFaceForward(MachineInstr &MI) const {
   MI.eraseFromParent();
 }
 
+/// This match is part of a combine that
+/// rewrites fmul (x,180/pi) to degrees(x)
+///   (f32 (g_fmul
+///          (f32 X)
+///          (f32 180/pi)))
+/// ->
+///   (f32 (g_intrinsic degrees
+///          (f32 X)))
+///
+/// The constant operand may also be a splat for vector types:
+///   (vXf32 (g_fmul
+///            (vXf32 X)
+///            (vXf32 splat(180/pi))))
+/// ->
+///   (vXf32 (g_intrinsic degrees
+///            (vXf32 X)))
+bool SPIRVCombinerHelper::matchDegrees(MachineInstr &MI) const {
----------------
albertbolt1 wrote:

I would still need to keep the part which checks for 180/pi in here right ? or is there a way to move that to tablegen as well

https://github.com/llvm/llvm-project/pull/216506


More information about the llvm-commits mailing list