[Test] Add a test exposing a miscompile in SimpleLoopUnswitch.
authorDaniil Suchkov <dsuchkov@azul.com>
Tue, 28 Sep 2021 23:30:50 +0000 (23:30 +0000)
committerDaniil Suchkov <dsuchkov@azul.com>
Fri, 1 Oct 2021 21:30:54 +0000 (21:30 +0000)
The miscompile was introduced by 6b4b1dc6ec6f0bf0a1bb414fbe751ccab99d41a0.

llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll [new file with mode: 0644]

diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-invariant-select-bug.ll
new file mode 100644 (file)
index 0000000..2f9d25c
--- /dev/null
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes='simple-loop-unswitch<nontrivial>' -S < %s | FileCheck %s
+
+; FIXME: We should not replace `true` with `false` here!
+define i1 @bar() {
+; CHECK-LABEL: @bar(
+; CHECK-NEXT:    ret i1 false
+;
+  ret i1 true
+}
+
+; FIXME: We shouldn't unswitch this loop!
+define void @foo() {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 true, label [[ENTRY_SPLIT_US:%.*]], label [[ENTRY_SPLIT:%.*]]
+; CHECK:       entry.split.us:
+; CHECK-NEXT:    br label [[HEADER_US:%.*]]
+; CHECK:       header.us:
+; CHECK-NEXT:    [[VAL_US:%.*]] = select i1 true, i1 true, i1 false
+; CHECK-NEXT:    br label [[EXIT_SPLIT_US:%.*]]
+; CHECK:       exit.split.us:
+; CHECK-NEXT:    br label [[EXIT:%.*]]
+; CHECK:       entry.split:
+; CHECK-NEXT:    br label [[HEADER:%.*]]
+; CHECK:       header:
+; CHECK-NEXT:    [[VAL:%.*]] = select i1 false, i1 false, i1 false
+; CHECK-NEXT:    br label [[HEADER]]
+; CHECK:       exit:
+; CHECK-NEXT:    ret void
+;
+entry:
+  br label %header
+
+header:
+  %val = select i1 true, i1 true, i1 false
+  br i1 %val, label %exit, label %header
+
+exit:
+  ret void
+}