forked from OSchip/llvm-project
[InstCombine] remove trunc user restriction for match of bswap
This does not appear to cause any problems, and it
fixes #50910
Extra tests with a trunc user were added with:
3a239379
...but they don't match either way, so there's an
opportunity to improve the matching further.
This commit is contained in:
parent
06cc2f2f12
commit
e2165e0968
|
@ -3147,11 +3147,6 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
|
|||
if (!ITy->isIntOrIntVectorTy() || ITy->getScalarSizeInBits() > 128)
|
||||
return false; // Can't do integer/elements > 128 bits.
|
||||
|
||||
Type *DemandedTy = ITy;
|
||||
if (I->hasOneUse())
|
||||
if (auto *Trunc = dyn_cast<TruncInst>(I->user_back()))
|
||||
DemandedTy = Trunc->getType();
|
||||
|
||||
// Try to find all the pieces corresponding to the bswap.
|
||||
bool FoundRoot = false;
|
||||
std::map<Value *, Optional<BitPart>> BPS;
|
||||
|
@ -3165,6 +3160,7 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
|
|||
"Illegal bit provenance index");
|
||||
|
||||
// If the upper bits are zero, then attempt to perform as a truncated op.
|
||||
Type *DemandedTy = ITy;
|
||||
if (BitProvenance.back() == BitPart::Unset) {
|
||||
while (!BitProvenance.empty() && BitProvenance.back() == BitPart::Unset)
|
||||
BitProvenance = BitProvenance.drop_back();
|
||||
|
|
|
@ -919,10 +919,7 @@ declare i64 @llvm.bswap.i64(i64)
|
|||
|
||||
define i32 @PR50910(i64 %t0) {
|
||||
; CHECK-LABEL: @PR50910(
|
||||
; CHECK-NEXT: [[T2:%.*]] = and i64 [[T0:%.*]], 72057594037927935
|
||||
; CHECK-NEXT: [[T3:%.*]] = call i64 @llvm.bswap.i64(i64 [[T2]])
|
||||
; CHECK-NEXT: [[T4:%.*]] = lshr i64 [[T0]], 56
|
||||
; CHECK-NEXT: [[T5:%.*]] = or i64 [[T3]], [[T4]]
|
||||
; CHECK-NEXT: [[T5:%.*]] = call i64 @llvm.bswap.i64(i64 [[T0:%.*]])
|
||||
; CHECK-NEXT: [[T6:%.*]] = trunc i64 [[T5]] to i32
|
||||
; CHECK-NEXT: ret i32 [[T6]]
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue