- Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
| Bugzilla Link | 42962 |
| Resolution | FIXED |
| Resolved on | Aug 13, 2019 04:57 |
| Version | trunk |
| OS | Windows NT |
| Blocks | #41819 |
| CC | @davidbolvansky,@zmodem,@LebedevRI,@RKSimon |
| Fixed by commit(s) | r368554 |
Extended Description
Given this IR (foo.ll):
;--------------------------------------------------------------------
@f.a = internal global i16 0
define dso_local void @f() local_unnamed_addr {
entry:
%0 = load i16, i16* @f.a
%shr = ashr i16 %0, 1
%shr1 = ashr i16 %shr, zext (i1 icmp ne (i16 ptrtoint (i16* @f.a to i16), i16 1) to i16)
%and = and i16 %shr1, 1
%tobool = icmp ne i16 %and, 0
br i1 %tobool, label %land.rhs, label %land.end
land.rhs:
br label %land.end
land.end:
ret void
}
;--------------------------------------------------------------------
we hit an assertion when running instcombine.
opt -instcombine -o - foo.ll -S
opt: ../include/llvm/Support/Casting.h:264: typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = llvm::BinaryOperator, Y = llvm::Value]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
Stack dump:
-
Program arguments: opt -instcombine -o - foo.ll -S -
Running pass 'Function Pass Manager' on module 'foo.ll'. -
Running pass 'Combine redundant instructions' on function '@f'
#0 0x00000000025455a4 PrintStackTraceSignalHandler(void*) (opt+0x25455a4)
#1 0x000000000254330e llvm::sys::RunSignalHandlers() (opt+0x254330e)
#2 0x00000000025459a8 SignalHandler(int) (opt+0x25459a8)
#3 0x0000003ba280f7e0 __restore_rt (/lib64/libpthread.so.0+0x3ba280f7e0)
#4 0x0000003ba24324f5 raise (/lib64/libc.so.6+0x3ba24324f5)
#5 0x0000003ba2433cd5 abort (/lib64/libc.so.6+0x3ba2433cd5)
#6 0x0000003ba242b66e __assert_fail_base (/lib64/libc.so.6+0x3ba242b66e)
#7 0x0000003ba242b730 __assert_perror_fail (/lib64/libc.so.6+0x3ba242b730)
#8 0x00000000020d3647 llvm::InstCombiner::foldICmpBinOp(llvm::ICmpInst&) (opt+0x20d3647)
#9 0x00000000020d9f3b llvm::InstCombiner::visitICmpInst(llvm::ICmpInst&) (opt+0x20d9f3b)
#10 0x00000000020640af llvm::InstCombiner::run() (opt+0x20640af)
#11 0x0000000002066491 combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::DominatorTree&, llvm::TargetTransformInfo const&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, llvm::LoopInfo*) (opt+0x2066491)
#12 0x0000000002066cee llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) (opt+0x2066cee)
#13 0x0000000001edf873 llvm::FPPassManager::runOnFunction(llvm::Function&) (opt+0x1edf873)
#14 0x0000000001edfb83 llvm::FPPassManager::runOnModule(llvm::Module&) (opt+0x1edfb83)
#15 0x0000000001ee01ed llvm::legacy::PassManagerImpl::run(llvm::Module&) (opt+0x1ee01ed)
#16 0x000000000080e9b7 main (opt+0x80e9b7)
#17 0x0000003ba241ed20 __libc_start_main (/lib64/libc.so.6+0x3ba241ed20)
#18 0x00000000007f5ff9 _start (opt+0x7f5ff9)
Abort (core dumped)
Afaict it started to happen after:
commit 72b8d41
Author: Roman Lebedev lebedev.ri@gmail.com
Date: Mon Jul 1 15:55:15 2019 +0000
[InstCombine] Shift amount reassociation in bittest (#42399 ) Summary: Given pattern: `icmp eq/ne (and ((x shift Q), (y oppositeshift K))), 0` we should move shifts to the same hand of 'and', i.e. rewrite as `icmp eq/ne (and (x shift (Q+K)), y), 0` iff `(Q+K) u< bitwidth(x)` It might be tempting to not restrict this to situations where we know we'd fold two shifts together, but i'm not sure what rules should there be to avoid endless combine loops. We pick the same shift that was originally used to shift the variable we picked to shift: https://rise4fun.com/Alive/6x1v Should fix [[ llvm/llvm-project#41744 | llvm/llvm-project#41744 ]]. Reviewers: spatel, nikic, RKSimon Reviewed By: spatel Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63829 llvm-svn: 364791