diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-11-15 17:19:14 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-15 17:19:14 +0000 |
| commit | bc56b2432d83d12168680e6b2b50f261d1ff2ded (patch) | |
| tree | baad2d46a31dc9f64db82b8196f9d471dc0732e3 /llvm/lib | |
| parent | af214885cd5eda8add23e22f17e82f9455f9e323 (diff) | |
| download | bcm5719-llvm-bc56b2432d83d12168680e6b2b50f261d1ff2ded.tar.gz bcm5719-llvm-bc56b2432d83d12168680e6b2b50f261d1ff2ded.zip | |
[InstCombine] fix rotate narrowing bug for non-pow-2 types
llvm-svn: 346968
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index a934e0aa68e..582f69fb2d2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -498,6 +498,13 @@ Instruction *InstCombiner::narrowRotate(TruncInst &Trunc) { shouldChangeType(Trunc.getSrcTy(), Trunc.getType())) && "Don't narrow to an illegal scalar type"); + // Bail out on strange types. It is possible to handle some of these patterns + // even with non-power-of-2 sizes, but it is not a likely scenario. + Type *DestTy = Trunc.getType(); + unsigned NarrowWidth = DestTy->getScalarSizeInBits(); + if (!isPowerOf2_32(NarrowWidth)) + return nullptr; + // First, find an or'd pair of opposite shifts with the same shifted operand: // trunc (or (lshr ShVal, ShAmt0), (shl ShVal, ShAmt1)) Value *Or0, *Or1; @@ -538,8 +545,6 @@ Instruction *InstCombiner::narrowRotate(TruncInst &Trunc) { return nullptr; }; - Type *DestTy = Trunc.getType(); - unsigned NarrowWidth = DestTy->getScalarSizeInBits(); Value *ShAmt = matchShiftAmount(ShAmt0, ShAmt1, NarrowWidth); bool SubIsOnLHS = false; if (!ShAmt) { |

