unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 4aec2cb6803f48421240d648780c3eed664ba078 2834 bytes (raw)
name: gnu/packages/patches/llvm-D42262-jumpthreading-not-i1.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
commit 6a311a7a804831fea43cfb2f61322adcb407a1af
Author: Keno Fischer <keno@juliacomputing.com>
Date:   Thu Jan 18 15:57:05 2018 -0500

    [JumpThreading] Don't restrict cast-traversal to i1
    
    Summary:
    In D17663, JumpThreading learned to look trough simple cast instructions,
    but only if the source of those cast instructions was a phi/cmp i1
    (in an effort to limit compile time effects). I think this condition
    is too restrictive. For switches with limited value range, InstCombine
    will readily introduce an extra `trunc` instruction to a smaller
    integer type (e.g. from i8 to i2), leaving us in the somewhat perverse
    situation that jump-threading would work before running instcombine,
    but not after. Since instcombine produces this pattern, I think we
    need to consider it canonical and support it in JumpThreading.
    In general, for limiting recursion, I think the existing restriction
    to phi and cmp nodes should be sufficient to avoid looking through
    unprofitable chains of instructions.
    
    Reviewers: haicheng, gberry, bmakam, mcrosier
    
    Subscribers: llvm-commits
    
    Differential Revision: https://reviews.llvm.org/D42262

diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 95c4650..1155e18 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -647,11 +647,9 @@ bool JumpThreadingPass::ComputeValueKnownInPredecessors(
   }
 
   // Handle Cast instructions.  Only see through Cast when the source operand is
-  // PHI or Cmp and the source type is i1 to save the compilation time.
+  // PHI or Cmp to save the compilation time.
   if (CastInst *CI = dyn_cast<CastInst>(I)) {
     Value *Source = CI->getOperand(0);
-    if (!Source->getType()->isIntegerTy(1))
-      return false;
     if (!isa<PHINode>(Source) && !isa<CmpInst>(Source))
       return false;
     ComputeValueKnownInPredecessors(Source, BB, Result, Preference, CxtI);
diff --git a/test/Transforms/JumpThreading/basic.ll b/test/Transforms/JumpThreading/basic.ll
index ce86cba..16e7549 100644
--- a/test/Transforms/JumpThreading/basic.ll
+++ b/test/Transforms/JumpThreading/basic.ll
@@ -547,6 +547,34 @@ l5:
 ; CHECK: }
 }
 
+define i1 @trunc_switch(i1 %arg) {
+; CHECK-LABEL: @trunc_switch
+top:
+; CHECK: br i1 %arg, label %exitA, label %exitB
+  br i1 %arg, label %common, label %B
+
+B:
+  br label %common
+
+common:
+  %phi = phi i8 [ 2, %B ], [ 1, %top ]
+  %trunc = trunc i8 %phi to i2
+; CHECK-NOT: switch
+  switch i2 %trunc, label %unreach [
+    i2 1, label %exitA
+    i2 -2, label %exitB
+  ]
+
+unreach:
+  unreachable
+
+exitA:
+  ret i1 true
+
+exitB:
+  ret i1 false
+}
+
 ; CHECK-LABEL: define void @h_con(i32 %p) {
 define void @h_con(i32 %p) {
   %x = icmp ult i32 %p, 5

debug log:

solving 4aec2cb68 ...
found 4aec2cb68 in https://yhetil.org/guix-patches/20190423094936.27413-1-anothersms@gmail.com/ ||
	https://yhetil.org/guix-patches/20190425075114.10284-1-anothersms@gmail.com/

applying [1/1] https://yhetil.org/guix-patches/20190423094936.27413-1-anothersms@gmail.com/
diff --git a/gnu/packages/patches/llvm-D42262-jumpthreading-not-i1.patch b/gnu/packages/patches/llvm-D42262-jumpthreading-not-i1.patch
new file mode 100644
index 0000000000..4aec2cb680

1:12: trailing whitespace.
    
1:26: trailing whitespace.
    
1:28: trailing whitespace.
    
1:30: trailing whitespace.
    
1:39: trailing whitespace.
 
Checking patch gnu/packages/patches/llvm-D42262-jumpthreading-not-i1.patch...
Applied patch gnu/packages/patches/llvm-D42262-jumpthreading-not-i1.patch cleanly.
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/20190425075114.10284-1-anothersms@gmail.com/ for 4aec2cb680
index at:
100644 4aec2cb6803f48421240d648780c3eed664ba078	gnu/packages/patches/llvm-D42262-jumpthreading-not-i1.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).