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

Paul Robinson Paul_Robinson at playstation.sony.com
Wed Mar 25 15:15:43 PDT 2015


Add a bit more detail to the comment explaining the test.
Run llc at -O0 to show we expect the combine at -O0, and also see it with optnone.


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,40 @@
+; RUN: llc < %s -mtriple=x86_64-pc-win32 -O0 | FileCheck %s
+; Verify that when an 'optnone' function bails out of fast-isel, it will run
+; the DAG combiner, just as -O0 would. (DAG combiner was disabled for 'optnone'
+; by r221168, re-enabled in r233153. This test makes sure it stays enabled.)
+;
+; 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.22682.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150325/8d1ee19c/attachment.bin>


More information about the llvm-commits mailing list