llvm.org GIT mirror llvm / 9fca970
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@234303 91177308-0d34-0410-b5e6-96231b3b80d8 Pawel Bylica 5 years ago
2 changed file(s) with 53 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
14221422
14231423 // If one or more successors has been unscheduled, then the current
14241424 // node is no longer available.
1425 if (!TrySU->isAvailable)
1425 if (!TrySU->isAvailable || !TrySU->NodeQueueId)
14261426 CurSU = AvailableQueue->pop();
14271427 else {
1428 // Available and in AvailableQueue
14281429 AvailableQueue->remove(TrySU);
14291430 CurSU = TrySU;
14301431 }
0 ; RUN: llc -march=x86-64 < %s -pre-RA-sched=list-ilp | FileCheck %s
1 ; RUN: llc -march=x86-64 < %s -pre-RA-sched=list-hybrid | FileCheck %s
2 ; RUN: llc -march=x86-64 < %s -pre-RA-sched=source | FileCheck %s
3 ; RUN: llc -march=x86-64 < %s -pre-RA-sched=list-burr | FileCheck %s
4 ; RUN: llc -march=x86-64 < %s -pre-RA-sched=linearize | FileCheck %s
5
6 ; PR22304 https://llvm.org/bugs/show_bug.cgi?id=22304
7 ; Tests checking backtracking in source scheduler. llc used to crash on them.
8
9 ; CHECK-LABEL: test1
10 define i256 @test1(i256 %a) {
11 %b = add i256 %a, 1
12 %m = shl i256 %b, 1
13 %p = add i256 %m, 1
14 %v = lshr i256 %b, %p
15 %t = trunc i256 %v to i1
16 %c = shl i256 1, %p
17 %f = select i1 %t, i256 undef, i256 %c
18 ret i256 %f
19 }
20
21 ; CHECK-LABEL: test2
22 define i256 @test2(i256 %a) {
23 %b = sub i256 0, %a
24 %c = and i256 %b, %a
25 %d = call i256 @llvm.ctlz.i256(i256 %c, i1 false)
26 ret i256 %d
27 }
28
29 ; CHECK-LABEL: test3
30 define i256 @test3(i256 %n) {
31 %m = sub i256 -1, %n
32 %x = sub i256 0, %n
33 %y = and i256 %x, %m
34 %z = call i256 @llvm.ctlz.i256(i256 %y, i1 false)
35 ret i256 %z
36 }
37
38 declare i256 @llvm.ctlz.i256(i256, i1) nounwind readnone
39
40 ; CHECK-LABEL: test4
41 define i64 @test4(i64 %a, i64 %b) {
42 %r = zext i64 %b to i256
43 %u = add i256 %r, 1
44 %w = and i256 %u, 1461501637330902918203684832716283019655932542975
45 %x = zext i64 %a to i256
46 %c = icmp uge i256 %w, %x
47 %y = select i1 %c, i64 0, i64 1
48 %z = add i64 %y, 1
49 ret i64 %z
50 }