[llvm-branch-commits] [llvm-branch] r233871 - Merging r233153 and r233584:
Paul Robinson
paul_robinson at playstation.sony.com
Wed Apr 1 17:15:35 PDT 2015
Author: probinson
Date: Wed Apr 1 19:15:35 2015
New Revision: 233871
URL: http://llvm.org/viewvc/llvm-project?rev=233871&view=rev
Log:
Merging r233153 and r233584:
------------------------------------------------------------------------
r233153 | probinson | 2015-03-24 17:10:24 -0700 (Tue, 24 Mar 2015) | 7 lines
'optnone' should not disable DAG combiner.
Reverts the code change from r221168 and the relevant test.
It was a mistake to disable the combiner, and based on the ultimate
definition of 'optnone' we shouldn't have considered the test case
as failing in the first place.
------------------------------------------------------------------------
r233584 | probinson | 2015-03-30 12:37:44 -0700 (Mon, 30 Mar 2015) | 9 lines
Verify 'optnone' can run DAG combiner when appropriate.
Adds a test to verify the behavior that r233153 restored: 'optnone'
does not spuriously disable the DAG combiner, and in fact there are
cases where the DAG combiner must run (even at -O0 or 'optnone') in
order for codegen to succeed.
Differential Revision: http://reviews.llvm.org/D8614
------------------------------------------------------------------------
Added:
llvm/branches/release_36/test/CodeGen/X86/dag-optnone.ll
Removed:
llvm/branches/release_36/test/CodeGen/X86/fastmath-optnone.ll
Modified:
llvm/branches/release_36/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/branches/release_36/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=233871&r1=233870&r2=233871&view=diff
==============================================================================
--- llvm/branches/release_36/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/branches/release_36/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Apr 1 19:15:35 2015
@@ -1160,13 +1160,6 @@ void DAGCombiner::Run(CombineLevel AtLev
LegalOperations = Level >= AfterLegalizeVectorOps;
LegalTypes = Level >= AfterLegalizeTypes;
- // Early exit if this basic block is in an optnone function.
- AttributeSet FnAttrs =
- DAG.getMachineFunction().getFunction()->getAttributes();
- if (FnAttrs.hasAttribute(AttributeSet::FunctionIndex,
- Attribute::OptimizeNone))
- return;
-
// Add all the dag nodes to the worklist.
for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(),
E = DAG.allnodes_end(); I != E; ++I)
Added: llvm/branches/release_36/test/CodeGen/X86/dag-optnone.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/CodeGen/X86/dag-optnone.ll?rev=233871&view=auto
==============================================================================
--- llvm/branches/release_36/test/CodeGen/X86/dag-optnone.ll (added)
+++ llvm/branches/release_36/test/CodeGen/X86/dag-optnone.ll Wed Apr 1 19:15:35 2015
@@ -0,0 +1,73 @@
+; RUN: llc < %s -mtriple=x86_64-pc-win32 -O0 -mattr=+avx | FileCheck %s
+
+; Background:
+; If fast-isel bails out to normal selection, then the DAG combiner will run,
+; even at -O0. In principle this should not happen (those are optimizations,
+; and we said -O0) but as a practical matter there are some instruction
+; selection patterns that depend on the legalizations and transforms that the
+; DAG combiner does.
+;
+; The 'optnone' attribute implicitly sets -O0 and fast-isel for the function.
+; The DAG combiner was disabled for 'optnone' (but not -O0) by r221168, then
+; re-enabled in r233153 because of problems with instruction selection patterns
+; mentioned above. (Note: because 'optnone' is supposed to match -O0, r221168
+; really should have disabled the combiner for both.)
+;
+; If instruction selection eventually becomes smart enough to run without DAG
+; combiner, then the combiner can be turned off for -O0 (not just 'optnone')
+; and this test can go away. (To be replaced by a different test that verifies
+; the DAG combiner does *not* run at -O0 or for 'optnone' functions.)
+;
+; In the meantime, this test wants to make sure the combiner stays enabled for
+; 'optnone' functions, just as it is for -O0.
+
+
+; The test cases @foo[WithOptnone] prove that the same DAG combine happens
+; with -O0 and with 'optnone' set. To prove this, we use a Windows triple to
+; cause fast-isel to bail out (because something about the calling convention
+; is not handled in fast-isel). Then we have a repeated fadd that can be
+; combined into an fmul. We show that this happens in both the non-optnone
+; function and the optnone function.
+
+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
+
+
+; The test case @bar is derived from an instruction selection failure case
+; that was solved by r233153. It depends on -mattr=+avx.
+; Really all we're trying to prove is that it doesn't crash any more.
+
+ at id84 = common global <16 x i32> zeroinitializer, align 64
+
+define void @bar() #1 {
+entry:
+ %id83 = alloca <16 x i8>, align 16
+ %0 = load <16 x i32>* @id84, align 64
+ %conv = trunc <16 x i32> %0 to <16 x i8>
+ store <16 x i8> %conv, <16 x i8>* %id83, align 16
+ ret void
+}
+
+attributes #0 = { "unsafe-fp-math"="true" }
+attributes #1 = { noinline optnone "unsafe-fp-math"="true" }
Removed: llvm/branches/release_36/test/CodeGen/X86/fastmath-optnone.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/CodeGen/X86/fastmath-optnone.ll?rev=233870&view=auto
==============================================================================
--- llvm/branches/release_36/test/CodeGen/X86/fastmath-optnone.ll (original)
+++ llvm/branches/release_36/test/CodeGen/X86/fastmath-optnone.ll (removed)
@@ -1,35 +0,0 @@
-; RUN: llc < %s -mcpu=corei7 -march=x86-64 -mattr=+sse2 | FileCheck %s
-; Verify that floating-point operations inside 'optnone' functions
-; are not optimized even if unsafe-fp-math is set.
-
-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-NOT: add
-; CHECK: 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: mul
-; CHECK: add
-; CHECK-NOT: mul
-; CHECK: add
-; CHECK-NOT: mul
-; CHECK: ret
-
-
-attributes #0 = { "unsafe-fp-math"="true" }
-attributes #1 = { noinline optnone "unsafe-fp-math"="true" }
More information about the llvm-branch-commits
mailing list