Index: lib/Transforms/IPO/MergeFunctions.cpp =================================================================== --- lib/Transforms/IPO/MergeFunctions.cpp +++ lib/Transforms/IPO/MergeFunctions.cpp @@ -1082,11 +1082,8 @@ Value *OpR = InstR->getOperand(i); if (int Res = cmpValues(OpL, OpR)) return Res; - if (int Res = cmpNumbers(OpL->getValueID(), OpR->getValueID())) - return Res; - // TODO: Already checked in cmpOperation - if (int Res = cmpTypes(OpL->getType(), OpR->getType())) - return Res; + // cmpValues should ensure this is true. + assert(cmpTypes(OpL->getType(), OpR->getType()) == 0); } } Index: test/Transforms/MergeFunc/merge-const-ptr-and-int.ll =================================================================== --- /dev/null +++ test/Transforms/MergeFunc/merge-const-ptr-and-int.ll @@ -0,0 +1,28 @@ +; RUN: opt -mergefunc -S < %s | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +; Afunc and Bfunc difer only in that one returns i64, the other a pointer. +; These should be merged. +define internal i64 @Afunc(i32* %P, i32* %Q) { + store i32 4, i32* %P + store i32 6, i32* %Q + ret i64 0 +} + +define internal i64* @Bfunc(i32* %P, i32* %Q) { + store i32 4, i32* %P + store i32 6, i32* %Q + ret i64* null +} + +define void @Cfunc(i32* %P, i32* %Q) { +; CHECK-LABEL: define void @Cfunc +; CHECK-NEXT: @Afunc +; CHECK-NEXT: @Afunc +; CHECK-NEXT: @Afunc +; CHECK-NEXT: ret void + call i64 @Afunc(i32* %P, i32* %Q) + call i64* @Bfunc(i32* %P, i32* %Q) + call i64 @Afunc(i32* %Q, i32* %P) + ret void +}