Treat xor of signbit like an add.
authorChris Lattner <sabre@nondot.org>
Mon, 2 Apr 2007 05:41:38 +0000 (05:41 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 2 Apr 2007 05:41:38 +0000 (05:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35586 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index 051631e80d14f3196210714c9e94833b55eb281e..3597b3551c923920c45a07ece52efd39047f06c5 100644 (file)
@@ -1427,7 +1427,16 @@ SCEVHandle ScalarEvolutionsImpl::createSCEV(Value *V) {
         }
       }
       break;
-      
+    case Instruction::Xor:
+      // If the RHS of the xor is a signbit, then this is just an add.
+      // Instcombine turns add of signbit into xor as a strength reduction step.
+      if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
+        if (CI->getValue().isSignBit())
+          return SCEVAddExpr::get(getSCEV(I->getOperand(0)),
+                                  getSCEV(I->getOperand(1)));
+      }
+      break;
+
     case Instruction::Shl:
       // Turn shift left of a constant amount into a multiply.
       if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {