[PATCH] Make sure to set trunc store action to Expand for all X86 targets.

Bob Wilson bob.wilson at apple.com
Mon Sep 8 18:23:38 PDT 2014


> On Sep 5, 2014, at 10:04 AM, Luqman Aden <me+llvm at luqman.ca> wrote:
> 
> Cool thanks! Could someone commit this for me?

Sure. Committed in r217410.

> 
> 
> On Sep 4, 2014, at 12:40 PM, Nadav Rotem <nrotem at apple.com> wrote:
> 
>> LGTM. 
>> 
>> 
>>> On Sep 4, 2014, at 8:26 AM, Luqman Aden <me+llvm at luqman.ca> wrote:
>>> 
>>> Ping?
>>> 
>>> On Aug 29, 2014, at 2:56 PM, Luqman Aden <me+llvm at luqman.ca> wrote:
>>> 
>>>> When compiling without SSE2, isTruncStoreLegal(F64, F32) would return Legal, whereas with SSE2 it would return Expand. And since the Target doesn't seem to actually handle a truncstore for double -> float, it would just output a store of a full double in the space for a float hence overwriting other bits on the stack.
>>>> 
>>>> ```
>>>> define void @bar() unnamed_addr {
>>>> entry-block:
>>>> %a = alloca double
>>>> %b = alloca float
>>>> 
>>>> store double 3.140000e+00, double* %a
>>>> %0 = load double* %a
>>>> 
>>>> %1 = fptrunc double %0 to float
>>>> store float %1, float* %b
>>>> 
>>>> ret void
>>>> }
>>>> ```
>>>> 
>>>> Without SSE2:
>>>> ```
>>>> bar:                                    # @bar
>>>> .cfi_startproc
>>>> # BB#0:                                 # %entry-block
>>>> subl    $20, %esp
>>>> .Ltmp0:
>>>> .cfi_def_cfa_offset 24
>>>> movl    $1074339512, 12(%esp)   # imm = 0x40091EB8
>>>> movl    $1374389535, 8(%esp)    # imm = 0x51EB851F                 0x40091EB851EB851F (double) 3.14
>>>> movl    $1074339512, 8(%esp)    # imm = 0x40091EB8
>>>> movl    $1374389535, 4(%esp)    # imm = 0x51EB851F
>>>> addl    $20, %esp
>>>> retl
>>>> ```
>>>> 
>>>> With SSE2:
>>>> ```
>>>> bar:                                    # @bar
>>>> .cfi_startproc
>>>> # BB#0:                                 # %entry-block
>>>> subl    $20, %esp
>>>> .Ltmp0:
>>>> .cfi_def_cfa_offset 24
>>>> movl    $1074339512, 12(%esp)   # imm = 0x40091EB8
>>>> movl    $1374389535, 8(%esp)    # imm = 0x51EB851F            0x40091EB851EB851F (double) 3.14
>>>> movl    $1078523331, 4(%esp)    # imm = 0x4048F5C3           0x4048F5C3 (float) 3.14
>>>> addl    $20, %esp
>>>> retl
>>>> ```
>>>> 
>>>> http://reviews.llvm.org/D5125
>>>> 
>>>> Files:
>>>> lib/Target/X86/X86ISelLowering.cpp
>>>> test/CodeGen/X86/dont-trunc-store-double-to-float.ll
>>>> <D5125.13098.patch>
>>> 
>> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list