Make SCEVAddRecExpr's getType return a pointer type when the add
authorDan Gohman <gohman@apple.com>
Tue, 19 Jan 2010 22:53:50 +0000 (22:53 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 19 Jan 2010 22:53:50 +0000 (22:53 +0000)
has a pointer member. This helps reduce unnecessary bitcasting
and uglygeps.

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

include/llvm/Analysis/ScalarEvolutionExpressions.h
test/CodeGen/X86/pr3495.ll

index 2c503506035e514c69cf4c359e1a7d04e2b23580..64b8b0bf7866c2391db36c956116b03a1635b86e 100644 (file)
@@ -295,6 +295,13 @@ namespace llvm {
   public:
     virtual const char *getOperationStr() const { return " + "; }
 
+    virtual const Type *getType() const {
+      // Use the type of the last operand, which is likely to be a pointer
+      // type, if there is one. This doesn't usually matter, but it can help
+      // reduce casts when the expressions are expanded.
+      return getOperand(getNumOperands() - 1)->getType();
+    }
+
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVAddExpr *S) { return true; }
     static inline bool classof(const SCEV *S) {
index 4b62bf40da4bff33cd38f06d3bb47c515ef0832d..1795970d353ee3c7e8d05fcaae7a73077a457890 100644 (file)
@@ -1,6 +1,6 @@
-; RUN: llc < %s -march=x86 -stats |& grep {Number of reloads omited} | grep 1
-; RUN: llc < %s -march=x86 -stats |& grep {Number of available reloads turned into copies} | grep 1
-; RUN: llc < %s -march=x86 -stats |& grep {Number of machine instrs printed} | grep 40
+; RUN: llc < %s -march=x86 -stats |& grep {Number of loads added} | grep 2
+; RUN: llc < %s -march=x86 -stats |& grep {Number of register spills} | grep 1
+; RUN: llc < %s -march=x86 -stats |& grep {Number of machine instrs printed} | grep 38
 ; PR3495
 ; The loop reversal kicks in once here, resulting in one fewer instruction.