[llvm-branch-commits] [llvm-branch] r234303 - Cherry-pick r233351, r233353, r233355: fix PR22304.
Pawel Bylica
chfast at gmail.com
Tue Apr 7 00:58:46 PDT 2015
Author: chfast
Date: Tue Apr 7 02:58:46 2015
New Revision: 234303
URL: http://llvm.org/viewvc/llvm-project?rev=234303&view=rev
Log:
Cherry-pick r233351, r233353, r233355: fix PR22304.
Original message from r233351:
Fix a bug in SelectionDAG scheduling backtracking code: PR22304.
It can happen (by line CurSU->isPending = true; // This SU is not in
AvailableQueue right now.) that a SUnit is mark as available but is
not in the AvailableQueue. For SUnit being selected for scheduling
both conditions must be met.
This patch mainly defensively protects from invalid removing a node
from a queue. Sometimes nodes are marked isAvailable but are not in
the queue because they have been defered due to some hazard.
The other two commits move a test from CodeGen/Generic to Codegen/X86.
Added:
llvm/branches/release_36/test/CodeGen/X86/scheduler-backtracking.ll
Modified:
llvm/branches/release_36/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
Modified: llvm/branches/release_36/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=234303&r1=234302&r2=234303&view=diff
==============================================================================
--- llvm/branches/release_36/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original)
+++ llvm/branches/release_36/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Tue Apr 7 02:58:46 2015
@@ -1423,9 +1423,10 @@ SUnit *ScheduleDAGRRList::PickNodeToSche
// If one or more successors has been unscheduled, then the current
// node is no longer available.
- if (!TrySU->isAvailable)
+ if (!TrySU->isAvailable || !TrySU->NodeQueueId)
CurSU = AvailableQueue->pop();
else {
+ // Available and in AvailableQueue
AvailableQueue->remove(TrySU);
CurSU = TrySU;
}
Added: llvm/branches/release_36/test/CodeGen/X86/scheduler-backtracking.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/CodeGen/X86/scheduler-backtracking.ll?rev=234303&view=auto
==============================================================================
--- llvm/branches/release_36/test/CodeGen/X86/scheduler-backtracking.ll (added)
+++ llvm/branches/release_36/test/CodeGen/X86/scheduler-backtracking.ll Tue Apr 7 02:58:46 2015
@@ -0,0 +1,51 @@
+; RUN: llc -march=x86-64 < %s -pre-RA-sched=list-ilp | FileCheck %s
+; RUN: llc -march=x86-64 < %s -pre-RA-sched=list-hybrid | FileCheck %s
+; RUN: llc -march=x86-64 < %s -pre-RA-sched=source | FileCheck %s
+; RUN: llc -march=x86-64 < %s -pre-RA-sched=list-burr | FileCheck %s
+; RUN: llc -march=x86-64 < %s -pre-RA-sched=linearize | FileCheck %s
+
+; PR22304 https://llvm.org/bugs/show_bug.cgi?id=22304
+; Tests checking backtracking in source scheduler. llc used to crash on them.
+
+; CHECK-LABEL: test1
+define i256 @test1(i256 %a) {
+ %b = add i256 %a, 1
+ %m = shl i256 %b, 1
+ %p = add i256 %m, 1
+ %v = lshr i256 %b, %p
+ %t = trunc i256 %v to i1
+ %c = shl i256 1, %p
+ %f = select i1 %t, i256 undef, i256 %c
+ ret i256 %f
+}
+
+; CHECK-LABEL: test2
+define i256 @test2(i256 %a) {
+ %b = sub i256 0, %a
+ %c = and i256 %b, %a
+ %d = call i256 @llvm.ctlz.i256(i256 %c, i1 false)
+ ret i256 %d
+}
+
+; CHECK-LABEL: test3
+define i256 @test3(i256 %n) {
+ %m = sub i256 -1, %n
+ %x = sub i256 0, %n
+ %y = and i256 %x, %m
+ %z = call i256 @llvm.ctlz.i256(i256 %y, i1 false)
+ ret i256 %z
+}
+
+declare i256 @llvm.ctlz.i256(i256, i1) nounwind readnone
+
+; CHECK-LABEL: test4
+define i64 @test4(i64 %a, i64 %b) {
+ %r = zext i64 %b to i256
+ %u = add i256 %r, 1
+ %w = and i256 %u, 1461501637330902918203684832716283019655932542975
+ %x = zext i64 %a to i256
+ %c = icmp uge i256 %w, %x
+ %y = select i1 %c, i64 0, i64 1
+ %z = add i64 %y, 1
+ ret i64 %z
+}
More information about the llvm-branch-commits
mailing list