Make SCEVAddRecExpr's getType return a pointer type when the add

has a pointer member. This helps reduce unnecessary bitcasting
and uglygeps.

llvm-svn: 93939
This commit is contained in:
Dan Gohman 2010-01-19 22:53:50 +00:00
parent aa6655557b
commit 221708d826
2 changed files with 10 additions and 3 deletions

View 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) {

View 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.