[PATCH] D153104: [DAG] Unroll and expand illegal result of LDEXP and POWI instead of widen.

Tianle Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 23:30:37 PDT 2023


liutianle created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
liutianle requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153104

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/test/CodeGen/X86/ldexp.ll


Index: llvm/test/CodeGen/X86/ldexp.ll
===================================================================
--- llvm/test/CodeGen/X86/ldexp.ll
+++ llvm/test/CodeGen/X86/ldexp.ll
@@ -106,30 +106,14 @@
 define <2 x float> @ldexp_v2f32(<2 x float> %val, <2 x i32> %exp) {
 ; X64-LABEL: ldexp_v2f32:
 ; X64:       # %bb.0:
-; X64-NEXT:    subq $72, %rsp
-; X64-NEXT:    .cfi_def_cfa_offset 80
+; X64-NEXT:    subq $56, %rsp
+; X64-NEXT:    .cfi_def_cfa_offset 64
 ; X64-NEXT:    movdqa %xmm1, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
-; X64-NEXT:    movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
-; X64-NEXT:    shufps {{.*#+}} xmm0 = xmm0[3,3,3,3]
-; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
-; X64-NEXT:    movd %xmm2, %edi
-; X64-NEXT:    callq ldexpf at PLT
 ; X64-NEXT:    movaps %xmm0, (%rsp) # 16-byte Spill
-; X64-NEXT:    movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
-; X64-NEXT:    movhlps {{.*#+}} xmm0 = xmm0[1,1]
-; X64-NEXT:    pshufd $238, {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Folded Reload
-; X64-NEXT:    # xmm1 = mem[2,3,2,3]
 ; X64-NEXT:    movd %xmm1, %edi
 ; X64-NEXT:    callq ldexpf at PLT
-; X64-NEXT:    unpcklps (%rsp), %xmm0 # 16-byte Folded Reload
-; X64-NEXT:    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
-; X64-NEXT:    movaps %xmm0, (%rsp) # 16-byte Spill
-; X64-NEXT:    movdqa {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
-; X64-NEXT:    movd %xmm0, %edi
-; X64-NEXT:    movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
-; X64-NEXT:    callq ldexpf at PLT
 ; X64-NEXT:    movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
-; X64-NEXT:    movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
+; X64-NEXT:    movaps (%rsp), %xmm0 # 16-byte Reload
 ; X64-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,1,1,1]
 ; X64-NEXT:    pshufd $85, {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Folded Reload
 ; X64-NEXT:    # xmm1 = mem[1,1,1,1]
@@ -137,10 +121,8 @@
 ; X64-NEXT:    callq ldexpf at PLT
 ; X64-NEXT:    movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Reload
 ; X64-NEXT:    unpcklps {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
-; X64-NEXT:    unpcklpd (%rsp), %xmm1 # 16-byte Folded Reload
-; X64-NEXT:    # xmm1 = xmm1[0],mem[0]
 ; X64-NEXT:    movaps %xmm1, %xmm0
-; X64-NEXT:    addq $72, %rsp
+; X64-NEXT:    addq $56, %rsp
 ; X64-NEXT:    .cfi_def_cfa_offset 8
 ; X64-NEXT:    retq
 ;
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -4087,8 +4087,12 @@
 
   case ISD::FLDEXP:
   case ISD::FPOWI:
-    Res = WidenVecRes_ExpOp(N);
-    break;
+    if (unrollExpandedOp())
+      break;
+    // If the target has custom/legal support for the scalar FP intrinsic ops
+    // (they are probably not destined to become libcalls), then widen those
+    // like any other unary ops.
+    [[fallthrough]];
 
   case ISD::ANY_EXTEND_VECTOR_INREG:
   case ISD::SIGN_EXTEND_VECTOR_INREG:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153104.531996.patch
Type: text/x-patch
Size: 3041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/206ab23a/attachment.bin>


More information about the llvm-commits mailing list