diff --git a/lib/Transforms/Scalar/EarlyCSE.cpp b/lib/Transforms/Scalar/EarlyCSE.cpp index 588939d96a6..39c86c7fc0b 100644 --- a/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/lib/Transforms/Scalar/EarlyCSE.cpp @@ -114,7 +114,7 @@ struct SimpleValue { isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || isa(Inst) || - isa(Inst); + isa(Inst) || isa(Inst); } }; @@ -268,6 +268,9 @@ static unsigned getHashValueImpl(SimpleValue Val) { 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 @@ static unsigned getHashValueImpl(SimpleValue Val) { 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/test/Transforms/EarlyCSE/basic.ll b/test/Transforms/EarlyCSE/basic.ll index 5797475c809..25d2dc3fd9b 100644 --- a/test/Transforms/EarlyCSE/basic.ll +++ b/test/Transforms/EarlyCSE/basic.ll @@ -291,3 +291,14 @@ entry: 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 +}