diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-04-16 22:10:36 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-04-16 22:10:36 +0000 |
| commit | 28a01b206981d871125ff94c9c33ac115b9d8c93 (patch) | |
| tree | a648b54c4a15e9d795e362b07df790b986e774bb /llvm/lib/Transforms | |
| parent | de9c04cff378d36c7fa791c55fa931acbf89aa1d (diff) | |
| download | bcm5719-llvm-28a01b206981d871125ff94c9c33ac115b9d8c93.tar.gz bcm5719-llvm-28a01b206981d871125ff94c9c33ac115b9d8c93.zip | |
* Clean up the code a bit
* Allow structs with negative offsets. This enables the em3d benchmark to
be made typesafe. In this case, the struct had an array as the first
element, so a negative index was ok (the expr was -8 + 8x)
llvm-svn: 2271
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/TransformInternals.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/TransformInternals.cpp b/llvm/lib/Transforms/TransformInternals.cpp index 06fa27822f7..55b9dda67e6 100644 --- a/llvm/lib/Transforms/TransformInternals.cpp +++ b/llvm/lib/Transforms/TransformInternals.cpp @@ -161,15 +161,12 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, // analysis::ExprType Expr = analysis::ClassifyExpression(OffsetVal); - // Get the offset and scale now... + // Get the offset and scale values if they exists... // A scale of zero with Expr.Var != 0 means a scale of 1. // - int Offset = 0; - int Scale = 0; + int Offset = Expr.Offset ? getConstantValue(Expr.Offset) : 0; + int Scale = Expr.Scale ? getConstantValue(Expr.Scale) : 0; - // Get the offset and scale values if they exists... - if (Expr.Offset) Offset = getConstantValue(Expr.Offset); - if (Expr.Scale) Scale = getConstantValue(Expr.Scale); if (Expr.Var && Scale == 0) Scale = 1; // Scale != 0 if Expr.Var != 0 // Loop over the Scale and Offset values, filling in the Indices vector for @@ -182,9 +179,8 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, CompTy = cast<CompositeType>(NextTy); if (const StructType *StructTy = dyn_cast<StructType>(CompTy)) { - if (Offset < 0) return 0; // Can't index negatively into structure // Step into the appropriate element of the structure... - unsigned ActualOffset = (unsigned)Offset; + unsigned ActualOffset = (Offset < 0) ? 0 : (unsigned)Offset; NextTy = getStructOffsetStep(StructTy, ActualOffset, Indices); Offset -= ActualOffset; } else { |

