Details
- Reviewers
foad arsenm - Commits
- rG40e00063bcb7: [GlobalISel] Combine fabs(fneg(x)) to fabs(x)
Diff Detail
Event Timeline
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h | ||
---|---|---|
371–376 | Would it be neater to combine these into a single "fabs of fabs-or-fneg" combine? |
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h | ||
---|---|---|
371–376 | There are actually not that similar. I do not delete anything because fneg might have multiple uses. Here is an interesting test that shows benefits even with multple uses of fneg(x): define amdgpu_vs float @test(float %x, float %y) { .entry: %negx = fneg float %x %absnegx = call float @llvm.fabs.f32(float %negx) %add1 = fadd float %absnegx, %y %add2 = fadd float %add1, %negx ret float %add2 } declare float @llvm.fabs.f32(float) Before patch: v_xor_b32_e32 v2, 0x80000000, v0 v_add_f32_e64 v1, |v2|, v1 v_add_f32_e64 v0, v1, -v0 After patch: v_add_f32_e64 v1, |v0|, v1 v_add_f32_e64 v0, v1, -v0 |
Would it be neater to combine these into a single "fabs of fabs-or-fneg" combine?