From f79af6f8c4baf5018ef36aa462ca6f142fb2ed28 Mon Sep 17 00:00:00 2001 From: Michael Kuperstein Date: Thu, 8 Sep 2016 00:48:37 +0000 Subject: [CGP] Be less conservative about tail-duplicating a ret to allow tail calls CGP tail-duplicates rets into blocks that end with a call that feed the ret. This puts the call in tail position, potentially allowing the DAG builder to lower it as a tail call. To avoid tail duplication in cases where we won't form the tail call, CGP tried to predict whether this is going to be possible, and avoids doing it when lowering as a tail call will definitely fail. However, it was being too conservative by always throwing away calls to functions with a signext/zeroext attribute on the return type. Instead, we can use the same logic the builder uses to determine whether the attributes work out. Differential Revision: https://reviews.llvm.org/D24315 llvm-svn: 280894 --- llvm/test/CodeGen/X86/tailcall-cgp-dup.ll | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'llvm/test/CodeGen') diff --git a/llvm/test/CodeGen/X86/tailcall-cgp-dup.ll b/llvm/test/CodeGen/X86/tailcall-cgp-dup.ll index a51bc889924..26b43e7fe4d 100644 --- a/llvm/test/CodeGen/X86/tailcall-cgp-dup.ll +++ b/llvm/test/CodeGen/X86/tailcall-cgp-dup.ll @@ -85,3 +85,23 @@ someThingWithValue.exit: ; preds = %if.else.i, %if.then %retval.0.i = bitcast i8* %retval.0.in.i to %0* ret %0* %retval.0.i } + + +; Correctly handle zext returns. +declare zeroext i1 @foo_i1() + +; CHECK-LABEL: zext_i1 +; CHECK: jmp _foo_i1 +define zeroext i1 @zext_i1(i1 %k) { +entry: + br i1 %k, label %land.end, label %land.rhs + +land.rhs: ; preds = %entry + %call1 = tail call zeroext i1 @foo_i1() + br label %land.end + +land.end: ; preds = %entry, %land.rhs + %0 = phi i1 [ false, %entry ], [ %call1, %land.rhs ] + ret i1 %0 +} + -- cgit v1.2.3