[llvm-commits] [llvm] r73594 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/xor-and.ll

Dan Gohman gohman at apple.com
Tue Jun 16 18:22:40 PDT 2009


Author: djg
Date: Tue Jun 16 20:22:39 2009
New Revision: 73594

URL: http://llvm.org/viewvc/llvm-project?rev=73594&view=rev
Log:
Fix ScalarEvolution's Xor handling to not assume that an And
that gets recognized with a SCEVZeroExtendExpr must be an And
with a low-bits mask. With r73540, this is no longer the case.

Added:
    llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll
Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73594&r1=73593&r2=73594&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jun 16 20:22:39 2009
@@ -2453,9 +2453,12 @@
           if (BO->getOpcode() == Instruction::And &&
               LCI->getValue() == CI->getValue())
             if (const SCEVZeroExtendExpr *Z =
-                  dyn_cast<SCEVZeroExtendExpr>(getSCEV(U->getOperand(0))))
-              return getZeroExtendExpr(getNotSCEV(Z->getOperand()),
-                                       U->getType());
+                  dyn_cast<SCEVZeroExtendExpr>(getSCEV(U->getOperand(0)))) {
+              SCEVHandle ZO = Z->getOperand();
+              if (APIntOps::isMask(getTypeSizeInBits(ZO->getType()),
+                                   CI->getValue()))
+                return getZeroExtendExpr(getNotSCEV(ZO), U->getType());
+            }
     }
     break;
 

Added: llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll?rev=73594&view=auto

==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll (added)
+++ llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll Tue Jun 16 20:22:39 2009
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -disable-output -analyze | grep {\\-->  %z}
+
+; ScalarEvolution shouldn't try to analyze %s into something like
+;   -->  (zext i4 (-1 + (-1 * (trunc i64 (8 * %x) to i4))) to i64)
+
+define i64 @foo(i64 %x) {
+  %a = shl i64 %x, 3
+  %t = and i64 %a, 8
+  %z = xor i64 %t, 8
+  ret i64 %z
+}





More information about the llvm-commits mailing list