diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 32be3e0cdbf..e973cdbf44c 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1107,6 +1107,9 @@ CallOverdefined: Operands.push_back(State.getConstant()); } + if (getValueState(I).isOverdefined()) + return; + // If we can constant fold this, mark the result of the call as a // constant. if (Constant *C = ConstantFoldCall(F, Operands, TLI)) diff --git a/test/Transforms/SCCP/ipsccp-basic.ll b/test/Transforms/SCCP/ipsccp-basic.ll index c1c6c926fd9..107b7af2c1d 100644 --- a/test/Transforms/SCCP/ipsccp-basic.ll +++ b/test/Transforms/SCCP/ipsccp-basic.ll @@ -227,3 +227,23 @@ entry: ; CHECK-LABEL: define internal i32 @test10b( ; CHECK: ret i32 undef } + +;;======================== test11 + +define i64 @test11a() { + %xor = xor i64 undef, undef + ret i64 %xor +; CHECK-LABEL: define i64 @test11a +; CHECK: ret i64 0 +} + +define void @test11b() { + %call1 = call i64 @test11a() + %call2 = call i64 @llvm.ctpop.i64(i64 %call1) + ret void +; CHECK-LABEL: define void @test11b +; CHECK: %[[call1:.*]] = call i64 @test11a() +; CHECK: %[[call2:.*]] = call i64 @llvm.ctpop.i64(i64 0) +} + +declare i64 @llvm.ctpop.i64(i64)