mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 13:11:39 +01:00
[InstCombine] add extra use constraint for shl-zext fold
As the test shows, we can end up with more instructions than we started with if we don't include the extra-use check. llvm-svn: 367880
This commit is contained in:
parent
2028ac72f0
commit
3671d23fc9
@ -718,7 +718,7 @@ Instruction *InstCombiner::visitShl(BinaryOperator &I) {
|
||||
// shl (zext X), ShAmt --> zext (shl X, ShAmt)
|
||||
// This is only valid if X would have zeros shifted out.
|
||||
Value *X;
|
||||
if (match(Op0, m_ZExt(m_Value(X)))) {
|
||||
if (match(Op0, m_OneUse(m_ZExt(m_Value(X))))) {
|
||||
unsigned SrcWidth = X->getType()->getScalarSizeInBits();
|
||||
if (ShAmt < SrcWidth &&
|
||||
MaskedValueIsZero(X, APInt::getHighBitsSet(SrcWidth, ShAmt), 0, &I))
|
||||
|
@ -1198,8 +1198,7 @@ define i64 @shl_zext_extra_use(i32 %t) {
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[T:%.*]], 16777215
|
||||
; CHECK-NEXT: [[EXT:%.*]] = zext i32 [[AND]] to i64
|
||||
; CHECK-NEXT: call void @use(i64 [[EXT]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[T]], 8
|
||||
; CHECK-NEXT: [[SHL:%.*]] = zext i32 [[TMP1]] to i64
|
||||
; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i64 [[EXT]], 8
|
||||
; CHECK-NEXT: ret i64 [[SHL]]
|
||||
;
|
||||
%and = and i32 %t, 16777215
|
||||
|
Loading…
x
Reference in New Issue
Block a user