On Mon, Dec 25, 2017 at 12:52:56AM +0100, Patrick Wildt wrote:
> Hi,
> 
> gerhard@ found a bug in LLVM's i386 code.  He noticed that some floating
> point instructions were "optimized" and thus reordered between other FP
> instructions that changed floating point modes, so that those reordered
> instructions were running with an incorrent mode.
> 
> I don't completely grasp the internals, but it looks someone at LLVM
> took care of my bug report and changed some pseudo memory instructions
> to have side effects, so that they aren't reordered.  This has fixed
> our test case.
> 
> https://github.com/llvm-mirror/llvm/commit/63029e5caea7ef0af525e4f66249ca7ffa7e1280
> 
> ok?
> 

No objections, if this you are still looking for oks.

-ml

> Patrick
> 
> diff --git a/gnu/llvm/lib/Target/X86/X86InstrFPStack.td 
> b/gnu/llvm/lib/Target/X86/X86InstrFPStack.td
> index 11b1d070ef2..fb7eb87c64d 100644
> --- a/gnu/llvm/lib/Target/X86/X86InstrFPStack.td
> +++ b/gnu/llvm/lib/Target/X86/X86InstrFPStack.td
> @@ -139,6 +139,7 @@ def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, 
> RFP80:$src2), TwoArgFP,
>  // These instructions cannot address 80-bit memory.
>  multiclass FPBinary<SDNode OpNode, Format fp, string asmstring,
>                      bit Forward = 1> {
> +let mayLoad = 1, hasSideEffects = 1 in {
>  // ST(0) = ST(0) + [mem]
>  def _Fp32m  : FpIf32<(outs RFP32:$dst),
>                       (ins RFP32:$src1, f32mem:$src2), OneArgFPRW,
> @@ -175,10 +176,8 @@ def _Fp80m64: FpI_<(outs RFP80:$dst),
>                          (OpNode RFP80:$src1, (f80 (extloadf64 addr:$src2)))),
>                         (set RFP80:$dst,
>                          (OpNode (f80 (extloadf64 addr:$src2)), 
> RFP80:$src1)))]>;
> -let mayLoad = 1 in
>  def _F32m  : FPI<0xD8, fp, (outs), (ins f32mem:$src),
>                   !strconcat("f", asmstring, "{s}\t$src")>;
> -let mayLoad = 1 in
>  def _F64m  : FPI<0xDC, fp, (outs), (ins f64mem:$src),
>                   !strconcat("f", asmstring, "{l}\t$src")>;
>  // ST(0) = ST(0) + [memint]
> @@ -224,12 +223,11 @@ def _FpI32m80 : FpI_<(outs RFP80:$dst), (ins 
> RFP80:$src1, i32mem:$src2),
>                             (OpNode RFP80:$src1, (X86fild addr:$src2, i32))),
>                            (set RFP80:$dst,
>                             (OpNode (X86fild addr:$src2, i32), 
> RFP80:$src1)))]>;
> -let mayLoad = 1 in
>  def _FI16m  : FPI<0xDE, fp, (outs), (ins i16mem:$src),
>                    !strconcat("fi", asmstring, "{s}\t$src")>;
> -let mayLoad = 1 in
>  def _FI32m  : FPI<0xDA, fp, (outs), (ins i32mem:$src),
>                    !strconcat("fi", asmstring, "{l}\t$src")>;
> +} // mayLoad = 1, hasSideEffects = 1
>  }
>  
>  let Defs = [FPSW] in {
> 

Reply via email to