[PATCH] propagate IR-level fast-math-flags to DAG nodes, disabled by default

Nick Lewycky nlewycky at google.com
Fri Jun 19 16:53:26 PDT 2015


On 17 June 2015 at 13:57, Sanjay Patel <spatel at rotateright.com> wrote:

>
>
> On Wed, Jun 17, 2015 at 12:59 AM, Nick Lewycky <nicholas at mxc.ca> wrote:
>
>> Sanjay Patel wrote:
>>
>>> Please let me know if I can still take you up on this offer:
>>> "Could you add FMF under a flag and then let me test it before turning
>>> it on? I can test for compiler crashes in 24 hours, or for miscompiles over
>>> a weekend."
>>>
>>
>> Right! Yes, I can do that.
>>
>
> Great! Let me know when you see bugs crawling out from under the rug. :)
>

Just finished the first creduce.

Testcase:

int a, b, c;
void fn1() {
  b = c / (1.0 + c);
  a = 1 / (1.0 + c);
}

Build with "clang -O2 -mllvm -enable-fmf-dag -ffast-math" to get

 fatal error: error in backend: Cannot select: 0x2a8a760: f64 =
      ConstantFP<1.000000e+00> [ID=7]
In function: _Z3fn1v

and here it is as .ll:

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"

@a = global i32 0, align 4
@b = global i32 0, align 4
@c = global i32 0, align 4

; Function Attrs: nounwind uwtable
define void @_Z3fn1v() #0 {
  %1 = load i32, i32* @c, align 4, !tbaa !1
  %2 = sitofp i32 %1 to double
  %3 = fadd fast double %2, 1.000000e+00
  %4 = fdiv fast double %2, %3
  %5 = fptosi double %4 to i32
  store i32 %5, i32* @b, align 4, !tbaa !1
  %6 = fdiv fast double 1.000000e+00, %3
  %7 = fptosi double %6 to i32
  store i32 %7, i32* @a, align 4, !tbaa !1
  ret void
}

attributes #0 = { nounwind uwtable "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="true" "no-nans-fp-math"="true"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+sse,+sse2" "unsafe-fp-math"="true"
"use-soft-float"="false" }

!llvm.ident = !{!0}

!0 = !{!"clang version google3-trunk (trunk r240125)"}
!1 = !{!2, !2, i64 0}
!2 = !{!"int", !3, i64 0}
!3 = !{!"omnipotent char", !4, i64 0}
!4 = !{!"Simple C/C++ TBAA"}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150619/4feb98c5/attachment.html>


More information about the llvm-commits mailing list