]> granicus.if.org Git - llvm/commitdiff
[EarlyCSE] Add support for unary FNeg to EarlyCSE
authorCameron McInally <cameron.mcinally@nyu.edu>
Wed, 7 Aug 2019 14:34:41 +0000 (14:34 +0000)
committerCameron McInally <cameron.mcinally@nyu.edu>
Wed, 7 Aug 2019 14:34:41 +0000 (14:34 +0000)
Differential Revision: https://reviews.llvm.org/D65815

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368171 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/EarlyCSE.cpp
test/Transforms/EarlyCSE/floatingpoint.ll

index f1f07525702059d159ccc96a798d63fab915a9cb..22628ffa3e2b8eb12d67fd91050122e69acd7f80 100644 (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.
index de1c1eb4b417f4dbd3125087c306e97539814d33..998f86dff7590b4f097b7fec35e0f642c6f4153e 100644 (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