[EarlyCSE] Add support for unary FNeg to EarlyCSE

Differential Revision: https://reviews.llvm.org/D65815

llvm-svn: 368171
This commit is contained in:
Cameron McInally 2019-08-07 14:34:41 +00:00
parent 2e3a07fcb8
commit 303b6dbfb4
2 changed files with 9 additions and 9 deletions

View File

@ -108,11 +108,12 @@ struct SimpleValue {
// This can only handle non-void readnone functions.
if (CallInst *CI = dyn_cast<CallInst>(Inst))
return CI->doesNotAccessMemory() && !CI->getType()->isVoidTy();
return isa<CastInst>(Inst) || isa<BinaryOperator>(Inst) ||
isa<GetElementPtrInst>(Inst) || isa<CmpInst>(Inst) ||
isa<SelectInst>(Inst) || isa<ExtractElementInst>(Inst) ||
isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
isa<ExtractValueInst>(Inst) || isa<InsertValueInst>(Inst);
return isa<CastInst>(Inst) || isa<UnaryOperator>(Inst) ||
isa<BinaryOperator>(Inst) || isa<GetElementPtrInst>(Inst) ||
isa<CmpInst>(Inst) || isa<SelectInst>(Inst) ||
isa<ExtractElementInst>(Inst) || isa<InsertElementInst>(Inst) ||
isa<ShuffleVectorInst>(Inst) || isa<ExtractValueInst>(Inst) ||
isa<InsertValueInst>(Inst);
}
};
@ -240,7 +241,7 @@ static unsigned getHashValueImpl(SimpleValue Val) {
assert((isa<CallInst>(Inst) || isa<GetElementPtrInst>(Inst) ||
isa<ExtractElementInst>(Inst) || isa<InsertElementInst>(Inst) ||
isa<ShuffleVectorInst>(Inst)) &&
isa<ShuffleVectorInst>(Inst) || isa<UnaryOperator>(Inst)) &&
"Invalid/unknown instruction");
// Mix in the opcode.

View File

@ -17,9 +17,8 @@ define <4 x float> @fW( <4 x float> %a) {
; 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