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 | 2de2319124a74b2afff8a0cb1a272dc00b98e273 (patch) | |
tree | 960a8c9744db7b75c517f9363991e99ceb4858cc /lib/Transforms/Scalar | |
parent | 963f4ba8265f17c781e11e10cdc09e4c88bc5cf3 (diff) | |
download | external_llvm-2de2319124a74b2afff8a0cb1a272dc00b98e273.zip external_llvm-2de2319124a74b2afff8a0cb1a272dc00b98e273.tar.gz external_llvm-2de2319124a74b2afff8a0cb1a272dc00b98e273.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80508 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index a02aa5d..1bfce5d 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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, ... // |