[PATCH] D64403: [SimpleLoopUnswitch] Add a test case exposing a bug

Daniil Suchkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 04:52:00 PDT 2019


DaniilSuchkov created this revision.
DaniilSuchkov added reviewers: reames, asbirlea.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This test exposes a bug in SimpleLoopUnswitch that leads to a crash on `assert(SuccessorsCount > 1 && "Cannot unswitch a condition without multiple distinct successors!");` when SimpleLoopUnswitch considers unswitching of a loop by a switch with one successor.

Fix will be submitted soon.


https://reviews.llvm.org/D64403

Files:
  llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll


Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll
@@ -0,0 +1,25 @@
+; REQUIRES: asserts
+; XFAIL: *
+; RUN: opt -passes='unswitch<nontrivial>' -disable-output -S < %s
+; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -disable-output -S < %s
+
+; This loop shouldn't trigger asserts in SimpleLoopUnswitch.
+define void @test_redundant_switch(i1* %ptr, i32 %cond) {
+entry:
+  br label %loop_begin
+
+loop_begin:
+  switch i32 %cond, label %loop_body [
+      i32 0, label %loop_body
+  ]
+
+loop_body:
+  br label %loop_latch
+
+loop_latch:
+  %v = load i1, i1* %ptr
+  br i1 %v, label %loop_begin, label %loop_exit
+
+loop_exit:
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64403.208642.patch
Type: text/x-patch
Size: 859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190709/8ab0d6b3/attachment.bin>


More information about the llvm-commits mailing list