diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-30 20:38:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-30 20:38:21 +0000 |
commit | 73913f4cd3e86275e5b6cf55a1c8ed3c38c71516 (patch) | |
tree | 2b4990781a042af3d6eed7bf88e738e685163122 /llvm/lib | |
parent | c2f2cf896e3c5ca269eaf0621965d6e3378cc625 (diff) | |
download | bcm5719-llvm-73913f4cd3e86275e5b6cf55a1c8ed3c38c71516.tar.gz bcm5719-llvm-73913f4cd3e86275e5b6cf55a1c8ed3c38c71516.zip |
Fix PR4748: don't fold gep(bitcast(x)) into bitcast(gep) when x
is itself a bitcast. Since we have gep(bitcast(bitcast(y))) in this
case, just wait for the two bitcasts to get zapped. This prevents
instcombine from confusing some aliasing stuff, and allows it to
directly eliminate the load in the testcase.
llvm-svn: 80508
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index a02aa5dff8b..1bfce5dfcbd 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -10896,6 +10896,13 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (Value *X = getBitCastOperand(PtrOp)) { assert(isa<PointerType>(X->getType()) && "Must be cast from pointer"); + // If the input bitcast is actually "bitcast(bitcast(x))", then we don't + // want to change the gep until the bitcasts are eliminated. + if (getBitCastOperand(X)) { + Worklist.AddValue(PtrOp); + return 0; + } + // Transform: GEP (bitcast [10 x i8]* X to [0 x i8]*), i32 0, ... // into : GEP [10 x i8]* X, i32 0, ... // |