[PATCH] Verify 'optnone' can run DAG combiner when appropriate

Paul Robinson Paul_Robinson at playstation.sony.com
Wed Mar 25 13:17:09 PDT 2015


Hi dblaikie,

DAG combiner had been disabled for 'optnone' functions in r221168.
It was re-enabled in r233153. Add a test to keep it from happening again.

http://reviews.llvm.org/D8614

Files:
  test/CodeGen/X86/dag-optnone.ll

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" }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8614.22669.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150325/7e61d166/attachment.bin>


More information about the llvm-commits mailing list