Generalize target-independent folding rules for sizeof to handle more
authorDan Gohman <gohman@apple.com>
Mon, 1 Feb 2010 18:27:38 +0000 (18:27 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 1 Feb 2010 18:27:38 +0000 (18:27 +0000)
commit4f8eea82d8967cffa85b9df6c9255717b059009e
tree30c0ce1f31994e690d1e06b942a93fd36103449a
parentd569561835b0fa4dbbb0fca1b1f0a8de6c01439a
Generalize target-independent folding rules for sizeof to handle more
cases, and implement target-independent folding rules for alignof and
offsetof. Also, reassociate reassociative operators when it leads to
more folding.

Generalize ScalarEvolution's isOffsetOf to recognize offsetof on
arrays. Rename getAllocSizeExpr to getSizeOfExpr, and getFieldOffsetExpr
to getOffsetOfExpr, for consistency with analagous ConstantExpr routines.

Make the target-dependent folder promote GEP array indices to
pointer-sized integers, to make implicit casting explicit and exposed
to subsequent folding.

And add a bunch of testcases for this new functionality, and a bunch
of related existing functionality.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94987 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
include/llvm/Analysis/ScalarEvolutionExpressions.h
lib/Analysis/ConstantFolding.cpp
lib/Analysis/ScalarEvolution.cpp
lib/Analysis/ScalarEvolutionExpander.cpp
lib/VMCore/ConstantFold.cpp
test/Other/constant-fold-gep.ll
test/Transforms/InstCombine/getelementptr.ll