From 1c7efba2bddd6b17326a012d7bb77f3cf9668078 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 14 Oct 2004 05:12:50 +0000 Subject: [PATCH] When converting phi nodes into select instructions, we shouldn't promote PHI nodes unless we KNOW that we are able to promote all of them. In this case promoting the phi to a select is silly because we will always have to do the call conditionally. As such, select promotion is actually a pessimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16972 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/SimplifyCFG/PhiNoEliminate.ll | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/Transforms/SimplifyCFG/PhiNoEliminate.ll diff --git a/test/Transforms/SimplifyCFG/PhiNoEliminate.ll b/test/Transforms/SimplifyCFG/PhiNoEliminate.ll new file mode 100644 index 00000000000..6e7c9f5e782 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PhiNoEliminate.ll @@ -0,0 +1,29 @@ +; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep select + +;; The PHI node in this example should not be turned into a select, as we are +;; not able to ifcvt the entire block. As such, converting to a select just +;; introduces inefficiency without saving copies. + +int %bar(bool %C) { +entry: + br bool %C, label %then, label %endif + +then: + %tmp.3 = call int %qux() + br label %endif + +endif: + %R = phi int [123, %entry], [12312, %then] + ;; stuff to disable tail duplication + call int %qux() + call int %qux() + call int %qux() + call int %qux() + call int %qux() + call int %qux() + call int %qux() + ret int %R +} + +declare int %qux() + -- 2.11.0