[llvm] 11455e4 - [DAG] Unroll vectorized FPOW instructions before widening that will scalarize to libcalls anyway
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 07:45:04 PDT 2022
Author: Simon Pilgrim
Date: 2022-05-24T15:44:53+01:00
New Revision: 11455e47588940bd397e72e0c50811001c09295e
URL: https://github.com/llvm/llvm-project/commit/11455e47588940bd397e72e0c50811001c09295e
DIFF: https://github.com/llvm/llvm-project/commit/11455e47588940bd397e72e0c50811001c09295e.diff
LOG: [DAG] Unroll vectorized FPOW instructions before widening that will scalarize to libcalls anyway
Followup to D125988 - FPOW is similar to FREM and will most likely scalarize to libcalls, so unroll before widening to prevent use making additional libcalls with UNDEF args.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/X86/pow-libcall.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 835d5644cfb4f..ffb36ee155ece 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -3694,6 +3694,7 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
Res = WidenVecRes_Binary(N);
break;
+ case ISD::FPOW:
case ISD::FREM:
if (unrollExpandedOp())
break;
@@ -3704,7 +3705,6 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
case ISD::FADD:
case ISD::FMUL:
- case ISD::FPOW:
case ISD::FSUB:
case ISD::FDIV:
case ISD::SDIV:
diff --git a/llvm/test/CodeGen/X86/pow-libcall.ll b/llvm/test/CodeGen/X86/pow-libcall.ll
index e90155e5978cf..492418fffbbad 100644
--- a/llvm/test/CodeGen/X86/pow-libcall.ll
+++ b/llvm/test/CodeGen/X86/pow-libcall.ll
@@ -1,45 +1,30 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=x86_64-linux-gnu < %s | FileCheck %s
-; FIXME: Ensure vectorized FPOWs are not widened/unrolled such that they get lowered
+; Ensure vectorized FPOWs are not widened/unrolled such that they get lowered
; into libcalls on undef elements.
define float @test_fpow_v2f32_multiuse(<2 x float> %a0, <2 x float> %a1, <2 x float> *%p3) nounwind {
; CHECK-LABEL: test_fpow_v2f32_multiuse:
; CHECK: # %bb.0:
; CHECK-NEXT: pushq %rbx
-; CHECK-NEXT: subq $64, %rsp
+; CHECK-NEXT: subq $48, %rsp
; CHECK-NEXT: movq %rdi, %rbx
; CHECK-NEXT: movaps %xmm1, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
-; CHECK-NEXT: movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
-; CHECK-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,3,3,3]
-; CHECK-NEXT: shufps {{.*#+}} xmm1 = xmm1[3,3,3,3]
-; CHECK-NEXT: callq powf at PLT
; CHECK-NEXT: movaps %xmm0, (%rsp) # 16-byte Spill
-; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
-; CHECK-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1]
-; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Reload
-; CHECK-NEXT: movhlps {{.*#+}} xmm1 = xmm1[1,1]
-; CHECK-NEXT: callq powf at PLT
-; CHECK-NEXT: unpcklps (%rsp), %xmm0 # 16-byte Folded Reload
-; CHECK-NEXT: # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
-; CHECK-NEXT: movaps %xmm0, (%rsp) # 16-byte Spill
-; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
-; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Reload
; CHECK-NEXT: callq powf at PLT
; CHECK-NEXT: movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
-; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
+; CHECK-NEXT: movaps (%rsp), %xmm0 # 16-byte Reload
; CHECK-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,1,1,1]
; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Reload
; CHECK-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,1,1,1]
; CHECK-NEXT: callq powf at PLT
-; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Reload
+; CHECK-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm2 # 16-byte Reload
+; CHECK-NEXT: movaps %xmm2, %xmm1
; CHECK-NEXT: unpcklps {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
-; CHECK-NEXT: unpcklpd (%rsp), %xmm1 # 16-byte Folded Reload
-; CHECK-NEXT: # xmm1 = xmm1[0],mem[0]
-; CHECK-NEXT: addss %xmm1, %xmm0
+; CHECK-NEXT: addss %xmm2, %xmm0
; CHECK-NEXT: movlps %xmm1, (%rbx)
-; CHECK-NEXT: addq $64, %rsp
+; CHECK-NEXT: addq $48, %rsp
; CHECK-NEXT: popq %rbx
; CHECK-NEXT: retq
%fp = call <2 x float> @llvm.pow.v2f32(<2 x float> %a0, <2 x float> %a1)
More information about the llvm-commits
mailing list