[clang] 1bb0caf - [X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match with ICC

Phoebe Wang via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 12 01:50:45 PST 2022


Author: Phoebe Wang
Date: 2022-01-12T17:50:37+08:00
New Revision: 1bb0caf561688681be67cc91560348c9e43fcbf3

URL: https://github.com/llvm/llvm-project/commit/1bb0caf561688681be67cc91560348c9e43fcbf3
DIFF: https://github.com/llvm/llvm-project/commit/1bb0caf561688681be67cc91560348c9e43fcbf3.diff

LOG: [X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match with ICC

MSVC currently doesn't support 80 bits long double. ICC supports it when
the option `/Qlong-double` is specified. Changing the alignment of f80
to 16 bytes so that we can be compatible with ICC's option.

Reviewed By: rnk, craig.topper

Differential Revision: https://reviews.llvm.org/D115942

Added: 
    

Modified: 
    clang/lib/Basic/Targets/X86.h
    clang/test/CodeGen/target-data.c
    llvm/lib/IR/AutoUpgrade.cpp
    llvm/lib/Target/X86/X86TargetMachine.cpp
    llvm/test/Bitcode/upgrade-datalayout3.ll
    llvm/test/CodeGen/X86/long-double-abi-align.ll
    llvm/test/CodeGen/X86/scalar-fp-to-i32.ll
    llvm/test/CodeGen/X86/scalar-fp-to-i64.ll
    llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index c952b8c9a3369..d1b66432e38b4 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -533,11 +533,12 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_32TargetInfo
     DoubleAlign = LongLongAlign = 64;
     bool IsWinCOFF =
         getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
-    resetDataLayout(IsWinCOFF ? "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:"
-                                "64-i64:64-f80:32-n8:16:32-a:0:32-S32"
-                              : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:"
-                                "64-i64:64-f80:32-n8:16:32-a:0:32-S32",
-                    IsWinCOFF ? "_" : "");
+    bool IsMSVC = getTriple().isWindowsMSVCEnvironment();
+    std::string Layout = IsWinCOFF ? "e-m:x" : "e-m:e";
+    Layout += "-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-";
+    Layout += IsMSVC ? "f80:128" : "f80:32";
+    Layout += "-n8:16:32-a:0:32-S32";
+    resetDataLayout(Layout, IsWinCOFF ? "_" : "");
   }
 };
 

diff  --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index d702f845112bd..e4150837279ce 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -8,7 +8,7 @@
 
 // RUN: %clang_cc1 -triple i686-unknown-win32 -emit-llvm -o - %s | \
 // RUN:     FileCheck --check-prefix=I686-WIN32 %s
-// I686-WIN32: target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32"
+// I686-WIN32: target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32"
 
 // RUN: %clang_cc1 -triple i686-unknown-cygwin -emit-llvm -o - %s | \
 // RUN:     FileCheck --check-prefix=I686-CYGWIN %s

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index a7c34caab1c3e..9b9325a2d741c 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4569,18 +4569,29 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
     return DL.empty() ? std::string("G1") : (DL + "-G1").str();
   }
 
+  std::string Res = DL.str();
   std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
   // If X86, and the datalayout matches the expected format, add pointer size
   // address spaces to the datalayout.
   if (!T.isX86() || DL.contains(AddrSpaces))
-    return std::string(DL);
+    return Res;
 
   SmallVector<StringRef, 4> Groups;
   Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
-  if (!R.match(DL, &Groups))
-    return std::string(DL);
+  if (R.match(DL, &Groups))
+    Res = (Groups[1] + AddrSpaces + Groups[3]).str();
+
+  // For 32-bit MSVC targets, raise the alignment of f80 values to 16 bytes.
+  // Raising the alignment is safe because Clang did not produce f80 values in
+  // the MSVC environment before this upgrade was added.
+  if (T.isWindowsMSVCEnvironment() && !T.isArch64Bit()) {
+    StringRef Ref = Res;
+    auto I = Ref.find("-f80:32-");
+    if (I != StringRef::npos)
+      Res = (Ref.take_front(I) + "-f80:128-" + Ref.drop_front(I + 8)).str();
+  }
 
-  return (Groups[1] + AddrSpaces + Groups[3]).str();
+  return Res;
 }
 
 void llvm::UpgradeAttributes(AttrBuilder &B) {

diff  --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index 78bc5519c23ff..e3d0128dd73da 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -127,7 +127,7 @@ static std::string computeDataLayout(const Triple &TT) {
   // Some ABIs align long double to 128 bits, others to 32.
   if (TT.isOSNaCl() || TT.isOSIAMCU())
     ; // No f80
-  else if (TT.isArch64Bit() || TT.isOSDarwin())
+  else if (TT.isArch64Bit() || TT.isOSDarwin() || TT.isWindowsMSVCEnvironment())
     Ret += "-f80:128";
   else
     Ret += "-f80:32";

diff  --git a/llvm/test/Bitcode/upgrade-datalayout3.ll b/llvm/test/Bitcode/upgrade-datalayout3.ll
index 526ba6069dc6f..6d95f2407acf4 100644
--- a/llvm/test/Bitcode/upgrade-datalayout3.ll
+++ b/llvm/test/Bitcode/upgrade-datalayout3.ll
@@ -5,4 +5,4 @@
 target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
 target triple = "i686-pc-windows-msvc"
 
-; CHECK: target datalayout = "e-m:w-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-S32"
+; CHECK: target datalayout = "e-m:w-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-S32"

diff  --git a/llvm/test/CodeGen/X86/long-double-abi-align.ll b/llvm/test/CodeGen/X86/long-double-abi-align.ll
index ca45886db5705..6a409f1b1dce1 100644
--- a/llvm/test/CodeGen/X86/long-double-abi-align.ll
+++ b/llvm/test/CodeGen/X86/long-double-abi-align.ll
@@ -11,7 +11,7 @@ define void @foo(i32 %0, x86_fp80 %1, i32 %2) nounwind {
 ; MSVC-NEXT:    movl %esp, %ebp
 ; MSVC-NEXT:    andl $-16, %esp
 ; MSVC-NEXT:    subl $32, %esp
-; MSVC-NEXT:    fldt 12(%ebp)
+; MSVC-NEXT:    fldt 24(%ebp)
 ; MSVC-NEXT:    fstpt (%esp)
 ; MSVC-NEXT:    leal 8(%ebp), %eax
 ; MSVC-NEXT:    pushl %eax
@@ -21,7 +21,7 @@ define void @foo(i32 %0, x86_fp80 %1, i32 %2) nounwind {
 ; MSVC-NEXT:    pushl %eax
 ; MSVC-NEXT:    calll _escape
 ; MSVC-NEXT:    addl $4, %esp
-; MSVC-NEXT:    leal 24(%ebp), %eax
+; MSVC-NEXT:    leal 40(%ebp), %eax
 ; MSVC-NEXT:    pushl %eax
 ; MSVC-NEXT:    calll _escape
 ; MSVC-NEXT:    addl $4, %esp

diff  --git a/llvm/test/CodeGen/X86/scalar-fp-to-i32.ll b/llvm/test/CodeGen/X86/scalar-fp-to-i32.ll
index 469c05d44813f..b22533a8c8ee2 100644
--- a/llvm/test/CodeGen/X86/scalar-fp-to-i32.ll
+++ b/llvm/test/CodeGen/X86/scalar-fp-to-i32.ll
@@ -344,8 +344,8 @@ define i32 @x_to_u32(x86_fp80 %a) nounwind {
 ; X86-AVX512-WIN:       # %bb.0:
 ; X86-AVX512-WIN-NEXT:    pushl %ebp
 ; X86-AVX512-WIN-NEXT:    movl %esp, %ebp
-; X86-AVX512-WIN-NEXT:    andl $-8, %esp
-; X86-AVX512-WIN-NEXT:    subl $8, %esp
+; X86-AVX512-WIN-NEXT:    andl $-16, %esp
+; X86-AVX512-WIN-NEXT:    subl $16, %esp
 ; X86-AVX512-WIN-NEXT:    fldt 8(%ebp)
 ; X86-AVX512-WIN-NEXT:    fisttpll (%esp)
 ; X86-AVX512-WIN-NEXT:    movl (%esp), %eax
@@ -382,8 +382,8 @@ define i32 @x_to_u32(x86_fp80 %a) nounwind {
 ; X86-SSE3-WIN:       # %bb.0:
 ; X86-SSE3-WIN-NEXT:    pushl %ebp
 ; X86-SSE3-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE3-WIN-NEXT:    andl $-8, %esp
-; X86-SSE3-WIN-NEXT:    subl $8, %esp
+; X86-SSE3-WIN-NEXT:    andl $-16, %esp
+; X86-SSE3-WIN-NEXT:    subl $16, %esp
 ; X86-SSE3-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE3-WIN-NEXT:    fisttpll (%esp)
 ; X86-SSE3-WIN-NEXT:    movl (%esp), %eax
@@ -420,8 +420,8 @@ define i32 @x_to_u32(x86_fp80 %a) nounwind {
 ; X86-SSE2-WIN:       # %bb.0:
 ; X86-SSE2-WIN-NEXT:    pushl %ebp
 ; X86-SSE2-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE2-WIN-NEXT:    andl $-8, %esp
-; X86-SSE2-WIN-NEXT:    subl $16, %esp
+; X86-SSE2-WIN-NEXT:    andl $-16, %esp
+; X86-SSE2-WIN-NEXT:    subl $32, %esp
 ; X86-SSE2-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE2-WIN-NEXT:    fnstcw {{[0-9]+}}(%esp)
 ; X86-SSE2-WIN-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
@@ -482,8 +482,8 @@ define i32 @x_to_u32(x86_fp80 %a) nounwind {
 ; X86-SSE1-WIN:       # %bb.0:
 ; X86-SSE1-WIN-NEXT:    pushl %ebp
 ; X86-SSE1-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE1-WIN-NEXT:    andl $-8, %esp
-; X86-SSE1-WIN-NEXT:    subl $16, %esp
+; X86-SSE1-WIN-NEXT:    andl $-16, %esp
+; X86-SSE1-WIN-NEXT:    subl $32, %esp
 ; X86-SSE1-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE1-WIN-NEXT:    fnstcw {{[0-9]+}}(%esp)
 ; X86-SSE1-WIN-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
@@ -516,8 +516,8 @@ define i32 @x_to_u32(x86_fp80 %a) nounwind {
 ; X87-WIN:       # %bb.0:
 ; X87-WIN-NEXT:    pushl %ebp
 ; X87-WIN-NEXT:    movl %esp, %ebp
-; X87-WIN-NEXT:    andl $-8, %esp
-; X87-WIN-NEXT:    subl $16, %esp
+; X87-WIN-NEXT:    andl $-16, %esp
+; X87-WIN-NEXT:    subl $32, %esp
 ; X87-WIN-NEXT:    fldt 8(%ebp)
 ; X87-WIN-NEXT:    fnstcw {{[0-9]+}}(%esp)
 ; X87-WIN-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
@@ -550,14 +550,27 @@ define i32 @x_to_u32(x86_fp80 %a) nounwind {
 }
 
 define i32 @x_to_s32(x86_fp80 %a) nounwind {
-; X86-AVX512-LABEL: x_to_s32:
-; X86-AVX512:       # %bb.0:
-; X86-AVX512-NEXT:    pushl %eax
-; X86-AVX512-NEXT:    fldt {{[0-9]+}}(%esp)
-; X86-AVX512-NEXT:    fisttpl (%esp)
-; X86-AVX512-NEXT:    movl (%esp), %eax
-; X86-AVX512-NEXT:    popl %ecx
-; X86-AVX512-NEXT:    retl
+; X86-AVX512-WIN-LABEL: x_to_s32:
+; X86-AVX512-WIN:       # %bb.0:
+; X86-AVX512-WIN-NEXT:    pushl %ebp
+; X86-AVX512-WIN-NEXT:    movl %esp, %ebp
+; X86-AVX512-WIN-NEXT:    andl $-16, %esp
+; X86-AVX512-WIN-NEXT:    subl $16, %esp
+; X86-AVX512-WIN-NEXT:    fldt 8(%ebp)
+; X86-AVX512-WIN-NEXT:    fisttpl {{[0-9]+}}(%esp)
+; X86-AVX512-WIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-AVX512-WIN-NEXT:    movl %ebp, %esp
+; X86-AVX512-WIN-NEXT:    popl %ebp
+; X86-AVX512-WIN-NEXT:    retl
+;
+; X86-AVX512-LIN-LABEL: x_to_s32:
+; X86-AVX512-LIN:       # %bb.0:
+; X86-AVX512-LIN-NEXT:    pushl %eax
+; X86-AVX512-LIN-NEXT:    fldt {{[0-9]+}}(%esp)
+; X86-AVX512-LIN-NEXT:    fisttpl (%esp)
+; X86-AVX512-LIN-NEXT:    movl (%esp), %eax
+; X86-AVX512-LIN-NEXT:    popl %ecx
+; X86-AVX512-LIN-NEXT:    retl
 ;
 ; X64-AVX512-WIN-LABEL: x_to_s32:
 ; X64-AVX512-WIN:       # %bb.0:
@@ -575,14 +588,27 @@ define i32 @x_to_s32(x86_fp80 %a) nounwind {
 ; X64-AVX512-LIN-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
 ; X64-AVX512-LIN-NEXT:    retq
 ;
-; X86-SSE3-LABEL: x_to_s32:
-; X86-SSE3:       # %bb.0:
-; X86-SSE3-NEXT:    pushl %eax
-; X86-SSE3-NEXT:    fldt {{[0-9]+}}(%esp)
-; X86-SSE3-NEXT:    fisttpl (%esp)
-; X86-SSE3-NEXT:    movl (%esp), %eax
-; X86-SSE3-NEXT:    popl %ecx
-; X86-SSE3-NEXT:    retl
+; X86-SSE3-WIN-LABEL: x_to_s32:
+; X86-SSE3-WIN:       # %bb.0:
+; X86-SSE3-WIN-NEXT:    pushl %ebp
+; X86-SSE3-WIN-NEXT:    movl %esp, %ebp
+; X86-SSE3-WIN-NEXT:    andl $-16, %esp
+; X86-SSE3-WIN-NEXT:    subl $16, %esp
+; X86-SSE3-WIN-NEXT:    fldt 8(%ebp)
+; X86-SSE3-WIN-NEXT:    fisttpl {{[0-9]+}}(%esp)
+; X86-SSE3-WIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-SSE3-WIN-NEXT:    movl %ebp, %esp
+; X86-SSE3-WIN-NEXT:    popl %ebp
+; X86-SSE3-WIN-NEXT:    retl
+;
+; X86-SSE3-LIN-LABEL: x_to_s32:
+; X86-SSE3-LIN:       # %bb.0:
+; X86-SSE3-LIN-NEXT:    pushl %eax
+; X86-SSE3-LIN-NEXT:    fldt {{[0-9]+}}(%esp)
+; X86-SSE3-LIN-NEXT:    fisttpl (%esp)
+; X86-SSE3-LIN-NEXT:    movl (%esp), %eax
+; X86-SSE3-LIN-NEXT:    popl %ecx
+; X86-SSE3-LIN-NEXT:    retl
 ;
 ; X64-SSE3-WIN-LABEL: x_to_s32:
 ; X64-SSE3-WIN:       # %bb.0:
@@ -600,20 +626,39 @@ define i32 @x_to_s32(x86_fp80 %a) nounwind {
 ; X64-SSE3-LIN-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
 ; X64-SSE3-LIN-NEXT:    retq
 ;
-; X86-SSE2-LABEL: x_to_s32:
-; X86-SSE2:       # %bb.0:
-; X86-SSE2-NEXT:    subl $8, %esp
-; X86-SSE2-NEXT:    fldt {{[0-9]+}}(%esp)
-; X86-SSE2-NEXT:    fnstcw (%esp)
-; X86-SSE2-NEXT:    movzwl (%esp), %eax
-; X86-SSE2-NEXT:    orl $3072, %eax # imm = 0xC00
-; X86-SSE2-NEXT:    movw %ax, {{[0-9]+}}(%esp)
-; X86-SSE2-NEXT:    fldcw {{[0-9]+}}(%esp)
-; X86-SSE2-NEXT:    fistpl {{[0-9]+}}(%esp)
-; X86-SSE2-NEXT:    fldcw (%esp)
-; X86-SSE2-NEXT:    movl {{[0-9]+}}(%esp), %eax
-; X86-SSE2-NEXT:    addl $8, %esp
-; X86-SSE2-NEXT:    retl
+; X86-SSE2-WIN-LABEL: x_to_s32:
+; X86-SSE2-WIN:       # %bb.0:
+; X86-SSE2-WIN-NEXT:    pushl %ebp
+; X86-SSE2-WIN-NEXT:    movl %esp, %ebp
+; X86-SSE2-WIN-NEXT:    andl $-16, %esp
+; X86-SSE2-WIN-NEXT:    subl $16, %esp
+; X86-SSE2-WIN-NEXT:    fldt 8(%ebp)
+; X86-SSE2-WIN-NEXT:    fnstcw (%esp)
+; X86-SSE2-WIN-NEXT:    movzwl (%esp), %eax
+; X86-SSE2-WIN-NEXT:    orl $3072, %eax # imm = 0xC00
+; X86-SSE2-WIN-NEXT:    movw %ax, {{[0-9]+}}(%esp)
+; X86-SSE2-WIN-NEXT:    fldcw {{[0-9]+}}(%esp)
+; X86-SSE2-WIN-NEXT:    fistpl {{[0-9]+}}(%esp)
+; X86-SSE2-WIN-NEXT:    fldcw (%esp)
+; X86-SSE2-WIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-SSE2-WIN-NEXT:    movl %ebp, %esp
+; X86-SSE2-WIN-NEXT:    popl %ebp
+; X86-SSE2-WIN-NEXT:    retl
+;
+; X86-SSE2-LIN-LABEL: x_to_s32:
+; X86-SSE2-LIN:       # %bb.0:
+; X86-SSE2-LIN-NEXT:    subl $8, %esp
+; X86-SSE2-LIN-NEXT:    fldt {{[0-9]+}}(%esp)
+; X86-SSE2-LIN-NEXT:    fnstcw (%esp)
+; X86-SSE2-LIN-NEXT:    movzwl (%esp), %eax
+; X86-SSE2-LIN-NEXT:    orl $3072, %eax # imm = 0xC00
+; X86-SSE2-LIN-NEXT:    movw %ax, {{[0-9]+}}(%esp)
+; X86-SSE2-LIN-NEXT:    fldcw {{[0-9]+}}(%esp)
+; X86-SSE2-LIN-NEXT:    fistpl {{[0-9]+}}(%esp)
+; X86-SSE2-LIN-NEXT:    fldcw (%esp)
+; X86-SSE2-LIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-SSE2-LIN-NEXT:    addl $8, %esp
+; X86-SSE2-LIN-NEXT:    retl
 ;
 ; X64-SSE2-WIN-LABEL: x_to_s32:
 ; X64-SSE2-WIN:       # %bb.0:
@@ -643,35 +688,73 @@ define i32 @x_to_s32(x86_fp80 %a) nounwind {
 ; X64-SSE2-LIN-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
 ; X64-SSE2-LIN-NEXT:    retq
 ;
-; X86-SSE1-LABEL: x_to_s32:
-; X86-SSE1:       # %bb.0:
-; X86-SSE1-NEXT:    subl $8, %esp
-; X86-SSE1-NEXT:    fldt {{[0-9]+}}(%esp)
-; X86-SSE1-NEXT:    fnstcw (%esp)
-; X86-SSE1-NEXT:    movzwl (%esp), %eax
-; X86-SSE1-NEXT:    orl $3072, %eax # imm = 0xC00
-; X86-SSE1-NEXT:    movw %ax, {{[0-9]+}}(%esp)
-; X86-SSE1-NEXT:    fldcw {{[0-9]+}}(%esp)
-; X86-SSE1-NEXT:    fistpl {{[0-9]+}}(%esp)
-; X86-SSE1-NEXT:    fldcw (%esp)
-; X86-SSE1-NEXT:    movl {{[0-9]+}}(%esp), %eax
-; X86-SSE1-NEXT:    addl $8, %esp
-; X86-SSE1-NEXT:    retl
+; X86-SSE1-WIN-LABEL: x_to_s32:
+; X86-SSE1-WIN:       # %bb.0:
+; X86-SSE1-WIN-NEXT:    pushl %ebp
+; X86-SSE1-WIN-NEXT:    movl %esp, %ebp
+; X86-SSE1-WIN-NEXT:    andl $-16, %esp
+; X86-SSE1-WIN-NEXT:    subl $16, %esp
+; X86-SSE1-WIN-NEXT:    fldt 8(%ebp)
+; X86-SSE1-WIN-NEXT:    fnstcw (%esp)
+; X86-SSE1-WIN-NEXT:    movzwl (%esp), %eax
+; X86-SSE1-WIN-NEXT:    orl $3072, %eax # imm = 0xC00
+; X86-SSE1-WIN-NEXT:    movw %ax, {{[0-9]+}}(%esp)
+; X86-SSE1-WIN-NEXT:    fldcw {{[0-9]+}}(%esp)
+; X86-SSE1-WIN-NEXT:    fistpl {{[0-9]+}}(%esp)
+; X86-SSE1-WIN-NEXT:    fldcw (%esp)
+; X86-SSE1-WIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-SSE1-WIN-NEXT:    movl %ebp, %esp
+; X86-SSE1-WIN-NEXT:    popl %ebp
+; X86-SSE1-WIN-NEXT:    retl
 ;
-; X87-LABEL: x_to_s32:
-; X87:       # %bb.0:
-; X87-NEXT:    subl $8, %esp
-; X87-NEXT:    fldt {{[0-9]+}}(%esp)
-; X87-NEXT:    fnstcw (%esp)
-; X87-NEXT:    movzwl (%esp), %eax
-; X87-NEXT:    orl $3072, %eax # imm = 0xC00
-; X87-NEXT:    movw %ax, {{[0-9]+}}(%esp)
-; X87-NEXT:    fldcw {{[0-9]+}}(%esp)
-; X87-NEXT:    fistpl {{[0-9]+}}(%esp)
-; X87-NEXT:    fldcw (%esp)
-; X87-NEXT:    movl {{[0-9]+}}(%esp), %eax
-; X87-NEXT:    addl $8, %esp
-; X87-NEXT:    retl
+; X86-SSE1-LIN-LABEL: x_to_s32:
+; X86-SSE1-LIN:       # %bb.0:
+; X86-SSE1-LIN-NEXT:    subl $8, %esp
+; X86-SSE1-LIN-NEXT:    fldt {{[0-9]+}}(%esp)
+; X86-SSE1-LIN-NEXT:    fnstcw (%esp)
+; X86-SSE1-LIN-NEXT:    movzwl (%esp), %eax
+; X86-SSE1-LIN-NEXT:    orl $3072, %eax # imm = 0xC00
+; X86-SSE1-LIN-NEXT:    movw %ax, {{[0-9]+}}(%esp)
+; X86-SSE1-LIN-NEXT:    fldcw {{[0-9]+}}(%esp)
+; X86-SSE1-LIN-NEXT:    fistpl {{[0-9]+}}(%esp)
+; X86-SSE1-LIN-NEXT:    fldcw (%esp)
+; X86-SSE1-LIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-SSE1-LIN-NEXT:    addl $8, %esp
+; X86-SSE1-LIN-NEXT:    retl
+;
+; X87-WIN-LABEL: x_to_s32:
+; X87-WIN:       # %bb.0:
+; X87-WIN-NEXT:    pushl %ebp
+; X87-WIN-NEXT:    movl %esp, %ebp
+; X87-WIN-NEXT:    andl $-16, %esp
+; X87-WIN-NEXT:    subl $16, %esp
+; X87-WIN-NEXT:    fldt 8(%ebp)
+; X87-WIN-NEXT:    fnstcw (%esp)
+; X87-WIN-NEXT:    movzwl (%esp), %eax
+; X87-WIN-NEXT:    orl $3072, %eax # imm = 0xC00
+; X87-WIN-NEXT:    movw %ax, {{[0-9]+}}(%esp)
+; X87-WIN-NEXT:    fldcw {{[0-9]+}}(%esp)
+; X87-WIN-NEXT:    fistpl {{[0-9]+}}(%esp)
+; X87-WIN-NEXT:    fldcw (%esp)
+; X87-WIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X87-WIN-NEXT:    movl %ebp, %esp
+; X87-WIN-NEXT:    popl %ebp
+; X87-WIN-NEXT:    retl
+;
+; X87-LIN-LABEL: x_to_s32:
+; X87-LIN:       # %bb.0:
+; X87-LIN-NEXT:    subl $8, %esp
+; X87-LIN-NEXT:    fldt {{[0-9]+}}(%esp)
+; X87-LIN-NEXT:    fnstcw (%esp)
+; X87-LIN-NEXT:    movzwl (%esp), %eax
+; X87-LIN-NEXT:    orl $3072, %eax # imm = 0xC00
+; X87-LIN-NEXT:    movw %ax, {{[0-9]+}}(%esp)
+; X87-LIN-NEXT:    fldcw {{[0-9]+}}(%esp)
+; X87-LIN-NEXT:    fistpl {{[0-9]+}}(%esp)
+; X87-LIN-NEXT:    fldcw (%esp)
+; X87-LIN-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X87-LIN-NEXT:    addl $8, %esp
+; X87-LIN-NEXT:    retl
   %r = fptosi x86_fp80 %a to i32
   ret i32 %r
 }

diff  --git a/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll b/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll
index 0ce9c87057467..718b8b558c9b2 100644
--- a/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll
+++ b/llvm/test/CodeGen/X86/scalar-fp-to-i64.ll
@@ -909,8 +909,8 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind {
 ; X86-AVX512-WIN:       # %bb.0:
 ; X86-AVX512-WIN-NEXT:    pushl %ebp
 ; X86-AVX512-WIN-NEXT:    movl %esp, %ebp
-; X86-AVX512-WIN-NEXT:    andl $-8, %esp
-; X86-AVX512-WIN-NEXT:    subl $8, %esp
+; X86-AVX512-WIN-NEXT:    andl $-16, %esp
+; X86-AVX512-WIN-NEXT:    subl $16, %esp
 ; X86-AVX512-WIN-NEXT:    fldt 8(%ebp)
 ; X86-AVX512-WIN-NEXT:    flds __real at 5f000000
 ; X86-AVX512-WIN-NEXT:    xorl %edx, %edx
@@ -985,8 +985,8 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind {
 ; X86-SSE3-WIN:       # %bb.0:
 ; X86-SSE3-WIN-NEXT:    pushl %ebp
 ; X86-SSE3-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE3-WIN-NEXT:    andl $-8, %esp
-; X86-SSE3-WIN-NEXT:    subl $8, %esp
+; X86-SSE3-WIN-NEXT:    andl $-16, %esp
+; X86-SSE3-WIN-NEXT:    subl $16, %esp
 ; X86-SSE3-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE3-WIN-NEXT:    flds __real at 5f000000
 ; X86-SSE3-WIN-NEXT:    xorl %edx, %edx
@@ -1061,8 +1061,8 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind {
 ; X86-SSE2-WIN:       # %bb.0:
 ; X86-SSE2-WIN-NEXT:    pushl %ebp
 ; X86-SSE2-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE2-WIN-NEXT:    andl $-8, %esp
-; X86-SSE2-WIN-NEXT:    subl $16, %esp
+; X86-SSE2-WIN-NEXT:    andl $-16, %esp
+; X86-SSE2-WIN-NEXT:    subl $32, %esp
 ; X86-SSE2-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE2-WIN-NEXT:    flds __real at 5f000000
 ; X86-SSE2-WIN-NEXT:    xorl %edx, %edx
@@ -1161,8 +1161,8 @@ define i64 @x_to_u64(x86_fp80 %a) nounwind {
 ; X87-WIN:       # %bb.0:
 ; X87-WIN-NEXT:    pushl %ebp
 ; X87-WIN-NEXT:    movl %esp, %ebp
-; X87-WIN-NEXT:    andl $-8, %esp
-; X87-WIN-NEXT:    subl $16, %esp
+; X87-WIN-NEXT:    andl $-16, %esp
+; X87-WIN-NEXT:    subl $32, %esp
 ; X87-WIN-NEXT:    fldt 8(%ebp)
 ; X87-WIN-NEXT:    flds __real at 5f000000
 ; X87-WIN-NEXT:    fucom %st(1)
@@ -1235,8 +1235,8 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind {
 ; X86-AVX512-WIN:       # %bb.0:
 ; X86-AVX512-WIN-NEXT:    pushl %ebp
 ; X86-AVX512-WIN-NEXT:    movl %esp, %ebp
-; X86-AVX512-WIN-NEXT:    andl $-8, %esp
-; X86-AVX512-WIN-NEXT:    subl $8, %esp
+; X86-AVX512-WIN-NEXT:    andl $-16, %esp
+; X86-AVX512-WIN-NEXT:    subl $16, %esp
 ; X86-AVX512-WIN-NEXT:    fldt 8(%ebp)
 ; X86-AVX512-WIN-NEXT:    fisttpll (%esp)
 ; X86-AVX512-WIN-NEXT:    movl (%esp), %eax
@@ -1275,8 +1275,8 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind {
 ; X86-SSE3-WIN:       # %bb.0:
 ; X86-SSE3-WIN-NEXT:    pushl %ebp
 ; X86-SSE3-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE3-WIN-NEXT:    andl $-8, %esp
-; X86-SSE3-WIN-NEXT:    subl $8, %esp
+; X86-SSE3-WIN-NEXT:    andl $-16, %esp
+; X86-SSE3-WIN-NEXT:    subl $16, %esp
 ; X86-SSE3-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE3-WIN-NEXT:    fisttpll (%esp)
 ; X86-SSE3-WIN-NEXT:    movl (%esp), %eax
@@ -1315,8 +1315,8 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind {
 ; X86-SSE2-WIN:       # %bb.0:
 ; X86-SSE2-WIN-NEXT:    pushl %ebp
 ; X86-SSE2-WIN-NEXT:    movl %esp, %ebp
-; X86-SSE2-WIN-NEXT:    andl $-8, %esp
-; X86-SSE2-WIN-NEXT:    subl $16, %esp
+; X86-SSE2-WIN-NEXT:    andl $-16, %esp
+; X86-SSE2-WIN-NEXT:    subl $32, %esp
 ; X86-SSE2-WIN-NEXT:    fldt 8(%ebp)
 ; X86-SSE2-WIN-NEXT:    fnstcw {{[0-9]+}}(%esp)
 ; X86-SSE2-WIN-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
@@ -1379,8 +1379,8 @@ define i64 @x_to_s64(x86_fp80 %a) nounwind {
 ; X87-WIN:       # %bb.0:
 ; X87-WIN-NEXT:    pushl %ebp
 ; X87-WIN-NEXT:    movl %esp, %ebp
-; X87-WIN-NEXT:    andl $-8, %esp
-; X87-WIN-NEXT:    subl $16, %esp
+; X87-WIN-NEXT:    andl $-16, %esp
+; X87-WIN-NEXT:    subl $32, %esp
 ; X87-WIN-NEXT:    fldt 8(%ebp)
 ; X87-WIN-NEXT:    fnstcw {{[0-9]+}}(%esp)
 ; X87-WIN-NEXT:    movzwl {{[0-9]+}}(%esp), %eax

diff  --git a/llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp b/llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
index ec900471a833e..0c835744e4fa7 100644
--- a/llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
+++ b/llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
@@ -24,7 +24,7 @@ TEST(DataLayoutUpgradeTest, ValidDataLayoutUpgrade) {
   EXPECT_EQ(DL1, "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64"
                  "-f80:128-n8:16:32:64-S128");
   EXPECT_EQ(DL2, "e-m:w-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64"
-                 "-f80:32-n8:16:32-S32");
+                 "-f80:128-n8:16:32-S32");
   EXPECT_EQ(DL3, "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128"
                  "-n32:64-S128");
 


        


More information about the cfe-commits mailing list