diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-28 01:36:16 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-28 01:36:16 +0000 |
commit | 35c3885ba1b7a5cf8d58ebc0bbd749a1e794eed5 (patch) | |
tree | 3861059a9e72d2ebf6afffdb5e8e162139ab6006 /lib/Transforms | |
parent | 7f491279351efd7d9d2947df4c514408e440634b (diff) | |
download | external_llvm-35c3885ba1b7a5cf8d58ebc0bbd749a1e794eed5.zip external_llvm-35c3885ba1b7a5cf8d58ebc0bbd749a1e794eed5.tar.gz external_llvm-35c3885ba1b7a5cf8d58ebc0bbd749a1e794eed5.tar.bz2 |
For PR1280:
When converting an add/xor/and triplet into a trunc/sext, only do so if the
intermediate integer type is a bitwidth that the targets can handle.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 7a868d8..ce9dab9 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1940,11 +1940,21 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { CFF80Val = APIntOps::ashr(CFF80Val, Size); } while (Size >= 1); - if (Size) { - const Type *MiddleType = IntegerType::get(Size); + // FIXME: This shouldn't be necessary. When the backends can handle types + // with funny bit widths then this whole cascade of if statements should + // be removed. It is just here to get the size of the "middle" type back + // up to something that the back ends can handle. + const Type *MiddleType = 0; + switch (Size) { + default: break; + case 32: MiddleType = Type::Int32Ty; break; + case 16: MiddleType = Type::Int16Ty; break; + case 8: MiddleType = Type::Int8Ty; break; + } + if (MiddleType) { Instruction *NewTrunc = new TruncInst(XorLHS, MiddleType, "sext"); InsertNewInstBefore(NewTrunc, I); - return new SExtInst(NewTrunc, I.getType()); + return new SExtInst(NewTrunc, I.getType(), I.getName()); } } } |