diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -114,7 +114,7 @@ isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || - isa(Inst); + isa(Inst) || isa(Inst); } }; @@ -268,6 +268,9 @@ if (CastInst *CI = dyn_cast(Inst)) return hash_combine(CI->getOpcode(), CI->getType(), CI->getOperand(0)); + if (FreezeInst *FI = dyn_cast(Inst)) + return hash_combine(FI->getOpcode(), FI->getOperand(0)); + if (const ExtractValueInst *EVI = dyn_cast(Inst)) return hash_combine(EVI->getOpcode(), EVI->getOperand(0), hash_combine_range(EVI->idx_begin(), EVI->idx_end())); @@ -279,7 +282,8 @@ assert((isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || - isa(Inst) || isa(Inst)) && + isa(Inst) || isa(Inst) || + isa(Inst)) && "Invalid/unknown instruction"); // Mix in the opcode. diff --git a/llvm/test/Transforms/EarlyCSE/basic.ll b/llvm/test/Transforms/EarlyCSE/basic.ll --- a/llvm/test/Transforms/EarlyCSE/basic.ll +++ b/llvm/test/Transforms/EarlyCSE/basic.ll @@ -291,3 +291,14 @@ store i32 2, i32* @c, align 4 ret void } + +define i1 @cse_freeze(i1 %a) { +entry: +; CHECK-LABEL: @cse_freeze( +; CHECK: %b = freeze i1 %a +; CHECK: ret i1 %b + %b = freeze i1 %a + %c = freeze i1 %a + %and = and i1 %b, %c + ret i1 %and +}