llvm-project/llvm/test/Transforms/LoopStrengthReduce
Roman Lebedev 8d081b78e4 SCEVExpander::expandAddRecExprLiterally(): check before casting as Instruction
Summary:
An alternative to D48597.
Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=37936 | PR37936 ]].

The problem is as follows:
1. `indvars` marks `%dec` as `NUW`.
2. `loop-instsimplify` runs `instsimplify`, which constant-folds `%dec` to -1 (D47908)
3. `loop-reduce` tries to do some further modification, but crashes
    with an type assertion in cast, because `%dec` is no longer an `Instruction`,

If the runline is split into two, i.e. you first run `-indvars -loop-instsimplify`,
store that into a file, and then run `-loop-reduce`, there is no crash.

So it looks like the problem is due to `-loop-instsimplify` not discarding SCEV.
But in this case we can just not crash if it's not an `Instruction`.
This is just a local fix, unlike D48597, so there may very well be other problems.

Reviewers: mkazantsev, uabelho, sanjoy, silviu.baranga, wmi

Reviewed By: mkazantsev

Subscribers: evstupac, javed.absar, spatel, llvm-commits

Differential Revision: https://reviews.llvm.org/D48599

llvm-svn: 335950
2018-06-29 07:44:20 +00:00
..
AArch64 Reapply [LSR] Create fewer redundant instructions. 2016-06-06 19:10:46 +00:00
AMDGPU reapply r334209 with fixes for harfbuzz in Chromium 2018-06-08 16:22:52 +00:00
ARM Generalize MergeBlockIntoPredecessor. Replace uses of MergeBasicBlockIntoOnlyPred. 2018-06-20 22:01:04 +00:00
NVPTX
X86 Generalize MergeBlockIntoPredecessor. Replace uses of MergeBasicBlockIntoOnlyPred. 2018-06-20 22:01:04 +00:00
2005-08-15-AddRecIV.ll
2005-08-17-OutOfLoopVariant.ll
2005-09-12-UsesOutOutsideOfLoop.ll
2007-04-23-UseIterator.ll
2008-08-13-CmpStride.ll
2008-09-09-Overflow.ll
2009-01-13-nonconstant-stride-outside-loop.ll
2009-04-28-no-reduce-mul.ll
2011-07-19-CritEdgeBreakCrash.ll
2011-10-03-CritEdgeMerge.ll
2011-10-06-ReusePhi.ll
2011-10-13-SCEVChain.ll
2011-10-14-IntPtr.ll
2011-12-19-PostincQuadratic.ll
2012-01-02-nopreheader.ll
2012-01-16-nopreheader.ll
2012-03-15-nopreheader.ll
2012-03-26-constexpr.ll
2012-07-13-ExpandUDiv.ll
2012-07-18-LimitReassociate.ll
2013-01-05-IndBr.ll
2013-01-14-ReuseCast.ll [LSR] Narrow search space by filtering non-optimal formulae with the same ScaledReg and Scale. 2017-07-06 15:52:14 +00:00
addrec-gep-address-space.ll
addrec-gep.ll
address-space-loop.ll
count-to-zero.ll
dead-phi.ll
different-type-ivs.ll
dominate-assert.ll
dont-hoist-simple-loop-constants.ll
dont_insert_redundant_ops.ll
dont_reduce_bytes.ll
dont_reverse.ll
ephemeral.ll
exit_compare_live_range.ll
funclet.ll [LoopStrengthReduce] Don't rewrite PHIs with incoming values from CatchSwitches 2016-02-03 21:30:34 +00:00
hoist-parent-preheader.ll
illegal-addr-modes.ll [ARM, Thumb1] Prevent ARMTargetLowering::isLegalAddressingMode from accepting illegal modes 2017-08-24 10:00:25 +00:00
invariant_value_first.ll
invariant_value_first_arg.ll
ivchain.ll [PM] Convert Loop Strength Reduce pass to new PM 2016-07-18 21:41:50 +00:00
lsr-comp-time.ll Fix LSR compile time hang. 2018-05-16 02:48:50 +00:00
negative-scale.ll
nested-reduce.ll
nonintegral.ll [SCEVExpander] Try harder to avoid introducing inttoptr 2017-05-27 03:22:55 +00:00
nonlinear-postinc.ll
ops_after_indvar.ll
phi_node_update_multiple_preds.ll
post-inc-icmpzero.ll [SCEV] Do not cache S -> V if S is not equivalent of V 2018-01-09 06:47:14 +00:00
post-inc-optsize.ll [LSR] Don't try and create post-inc expressions on non-rotated loops 2016-08-15 07:53:03 +00:00
pr2537.ll
pr2570.ll
pr3086.ll
pr3399.ll
pr3571.ll
pr12018.ll Remove the obsolete offset parameter from @llvm.dbg.value 2017-07-28 20:21:02 +00:00
pr12048.ll
pr12691.ll
pr18165.ll
pr25541.ll
pr27056.ll Fix PR33514 2017-08-04 18:46:13 +00:00
pr31627.ll [LoopStrengthReduce] Don't bother rewriting PHIs in catchswitch blocks 2017-01-13 22:24:27 +00:00
preserve-gep-loop-variant.ll
related_indvars.ll
remove_indvar.ll
scaling_factor_cost_crash.ll
scev-after-loopinstsimplify.ll SCEVExpander::expandAddRecExprLiterally(): check before casting as Instruction 2018-06-29 07:44:20 +00:00
scev-insertpt-bug.ll Reapply [LSR] Create fewer redundant instructions. 2016-06-06 19:10:46 +00:00
sext-ind-var.ll [SCEV] Preserve NSW information for sext(subtract). 2017-08-04 20:19:46 +00:00
share_code_in_preheader.ll
share_ivs.ll
shl.ll
uglygep-address-space.ll
uglygep.ll
use_postinc_value_outside_loop.ll
var_stride_used_by_compare.ll
variable_stride.ll