Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grep FSGNJX #1072

Closed
dtcxzyw opened this issue Jul 25, 2024 · 1 comment · Fixed by llvm/llvm-project#100718
Closed

Grep FSGNJX #1072

dtcxzyw opened this issue Jul 25, 2024 · 1 comment · Fixed by llvm/llvm-project#100718
Assignees
Labels

Comments

@dtcxzyw
Copy link
Owner

dtcxzyw commented Jul 25, 2024

define float @test(float %x, float %y) {
  %z = call float @llvm.copysign.i32(float 1.0, float %x)
  %mul = fmul float %z, %y
  ret float %mul
}

https://alive2.llvm.org/ce/z/epyL33

@dtcxzyw dtcxzyw added the grep label Jul 25, 2024
Copy link
Contributor

proj/optimized/geodesic.c.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %238 = tail call double @llvm.copysign.f64(double 1.000000e+00, double %218)
  %mul = fmul float %z, %y  ->  %245 = fmul double %238, %235

pbrt-v4/optimized/lightsamplers.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %9 = tail call <2 x float> @llvm.copysign.v2f32(<2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> %4)
  %mul = fmul float %z, %y  ->  %10 = fmul <2 x float> %9, %8

pbrt-v4/optimized/integrator.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %80 = tail call <2 x float> @llvm.copysign.v2f32(<2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> %75)
  %mul = fmul float %z, %y  ->  %81 = fmul <2 x float> %80, %79

pbrt-v4/optimized/subsurface.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %80 = tail call <2 x float> @llvm.copysign.v2f32(<2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> %75)
  %mul = fmul float %z, %y  ->  %81 = fmul <2 x float> %80, %79

pbrt-v4/optimized/surfscatter.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %80 = tail call <2 x float> @llvm.copysign.v2f32(<2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> %75)
  %mul = fmul float %z, %y  ->  %81 = fmul <2 x float> %80, %79

pbrt-v4/optimized/integrators.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %80 = tail call <2 x float> @llvm.copysign.v2f32(<2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> %75)
  %mul = fmul float %z, %y  ->  %81 = fmul <2 x float> %80, %79

ocio/optimized/GammaOpCPU.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %27 = tail call <4 x float> @llvm.copysign.v4f32(<4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float> %26)
  %mul = fmul float %z, %y  ->  %44 = fmul <4 x float> %27, %43

ocio/optimized/FixedFunctionOpCPU.cpp.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %9 = tail call float @llvm.copysign.f32(float 1.000000e+00, float %mul.i)
  %mul = fmul float %z, %y  ->  %neg.i = fmul float %9, -5.000000e-01

cpython/optimized/mathmodule.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %2 = tail call double @llvm.copysign.f64(double 1.000000e+00, double %x)
  %mul = fmul float %z, %y  ->  %mul18 = fmul double %2, %r.0

ruby/optimized/numeric.ll
  %z = call float @llvm.copysign.f32(float 1.000000e+00, float %x)  ->  %36 = tail call double @llvm.copysign.f64(double 1.000000e+00, double %.0.i411)
  %mul = fmul float %z, %y  ->  %37 = fmul double %.0.i, %36

10 Occurrences

@dtcxzyw dtcxzyw self-assigned this Jul 25, 2024
dtcxzyw added a commit to llvm/llvm-project that referenced this issue Jul 27, 2024
This patch folds `fmul X, (fcopysign 1.0, Y)` into `fsgnjx X, Y`. This
pattern exists in some graphics applications/math libraries.
Alive2: https://alive2.llvm.org/ce/z/epyL33

Since fpimm +1.0 is lowered to a load from constant pool after
OpLegalization, I have to introduce a new RISCVISD node FSGNJX and fold
this pattern in DAGCombine.

Closes dtcxzyw/llvm-opt-benchmark#1072.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant