[llvm] r199564 - Don't refuse to transform constexpr(call(arg, ...)) to call(constexpr(arg), ...)) just because the function has multiple return values even if their return types are the same. Patch by Eduard Burtescu!
Nick Lewycky
nicholas at mxc.ca
Sat Jan 18 14:47:12 PST 2014
Author: nicholas
Date: Sat Jan 18 16:47:12 2014
New Revision: 199564
URL: http://llvm.org/viewvc/llvm-project?rev=199564&view=rev
Log:
Don't refuse to transform constexpr(call(arg, ...)) to call(constexpr(arg), ...)) just because the function has multiple return values even if their return types are the same. Patch by Eduard Burtescu!
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/trunk/test/Transforms/InstCombine/call-cast-target.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=199564&r1=199563&r2=199564&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Sat Jan 18 16:47:12 2014
@@ -994,11 +994,12 @@ bool InstCombiner::transformConstExprCas
Type *OldRetTy = Caller->getType();
Type *NewRetTy = FT->getReturnType();
- if (NewRetTy->isStructTy())
- return false; // TODO: Handle multiple return values.
-
// Check to see if we are changing the return type...
if (OldRetTy != NewRetTy) {
+
+ if (NewRetTy->isStructTy())
+ return false; // TODO: Handle multiple return values.
+
if (!CastInst::isBitCastable(NewRetTy, OldRetTy)) {
if (Callee->isDeclaration())
return false; // Cannot transform this return value.
Modified: llvm/trunk/test/Transforms/InstCombine/call-cast-target.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/call-cast-target.ll?rev=199564&r1=199563&r2=199564&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/call-cast-target.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/call-cast-target.ll Sat Jan 18 16:47:12 2014
@@ -13,3 +13,15 @@ entry:
declare i8* @ctime(i32*)
+define internal { i8 } @foo(i32*) {
+entry:
+ ret { i8 } { i8 0 }
+}
+
+define void @test_struct_ret() {
+; CHECK-LABEL: @test_struct_ret
+; CHECK-NOT: bitcast
+entry:
+ %0 = call { i8 } bitcast ({ i8 } (i32*)* @foo to { i8 } (i16*)*)(i16* null)
+ ret void
+}
More information about the llvm-commits
mailing list