Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp =================================================================== --- llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -108,11 +108,12 @@ // This can only handle non-void readnone functions. if (CallInst *CI = dyn_cast(Inst)) return CI->doesNotAccessMemory() && !CI->getType()->isVoidTy(); - return isa(Inst) || isa(Inst) || - isa(Inst) || isa(Inst) || - isa(Inst) || isa(Inst) || - isa(Inst) || isa(Inst) || - isa(Inst) || isa(Inst); + return isa(Inst) || isa(Inst) || + isa(Inst) || isa(Inst) || + isa(Inst) || isa(Inst) || + isa(Inst) || isa(Inst) || + isa(Inst) || isa(Inst) || + isa(Inst); } }; @@ -163,6 +164,12 @@ static unsigned getHashValueImpl(SimpleValue Val) { Instruction *Inst = Val.Inst; + + if (UnaryOperator *UnOp = dyn_cast(Inst)) { + return hash_combine(UnOp->getOpcode(), UnOp->getType(), + UnOp->getOperand(0)); + } + // Hash in all of the operands as pointers. if (BinaryOperator *BinOp = dyn_cast(Inst)) { Value *LHS = BinOp->getOperand(0); Index: llvm/test/Transforms/EarlyCSE/floatingpoint.ll =================================================================== --- llvm/test/Transforms/EarlyCSE/floatingpoint.ll +++ llvm/test/Transforms/EarlyCSE/floatingpoint.ll @@ -17,9 +17,8 @@ ; CSE unary fnegs. define void @fX(<4 x float> *%p, <4 x float> %a) { ; CHECK: %x = fneg <4 x float> %a - ; CHECK: %y = fneg <4 x float> %a - ; CHECK-NEXT: store volatile <4 x float> %x, <4 x float>* %p - ; CHECK-NEXT: store volatile <4 x float> %y, <4 x float>* %p + ; CHECK-NEXT: store volatile <4 x float> %x, <4 x float>* %p + ; CHECK-NEXT: store volatile <4 x float> %x, <4 x float>* %p %x = fneg <4 x float> %a %y = fneg <4 x float> %a store volatile <4 x float> %x, <4 x float>* %p