Index: test/CodeGen/X86/dag-optnone.ll =================================================================== --- test/CodeGen/X86/dag-optnone.ll +++ test/CodeGen/X86/dag-optnone.ll @@ -0,0 +1,38 @@ +; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s +; Verify that when an 'optnone' function bails out of fast-isel, it will run +; the DAG combiner. (This was disabled by r221168, re-enabled in r233153.) +; We set unsafe-fp-math which allows the DAG combiner to fold the fadd sequence +; into an fmul. We have a non-optnone function doing the same thing, to show +; that the combine is expected. +; Note, this will start failing if somebody decides that this combine should +; not occur at -O0 (because 'optnone' essentially sets -O0 for the function). +; FIXME: We use a Windows triple because the calling convention ends up causing +; fast-isel to bail out. A more robust tactic for ensuring fast-isel will +; bail out would be better. + +define float @foo(float %x) #0 { +entry: + %add = fadd fast float %x, %x + %add1 = fadd fast float %add, %x + ret float %add1 +} + +; CHECK-LABEL: @foo +; CHECK-NOT: add +; CHECK: mul +; CHECK-NEXT: ret + +define float @fooWithOptnone(float %x) #1 { +entry: + %add = fadd fast float %x, %x + %add1 = fadd fast float %add, %x + ret float %add1 +} + +; CHECK-LABEL: @fooWithOptnone +; CHECK-NOT: add +; CHECK: mul +; CHECK-NEXT: ret + +attributes #0 = { "unsafe-fp-math"="true" } +attributes #1 = { noinline optnone "unsafe-fp-math"="true" }