Extend jump threading to support much more general threading

predicates.  This allows us to jump thread things like:

_ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit119:
  %tmp1.i24166 = phi i8 [ 1, %bb5.i117 ], [ %tmp1.i24165, %_Z....exit ], [ %tmp1.i24165, %bb4.i114 ] 
  %toBoolnot.i87 = icmp eq i8 %tmp1.i24166, 0     ; <i1> [#uses=1]
  %tmp4.i90 = icmp eq i32 %tmp2.i, 6              ; <i1> [#uses=1]
  %or.cond173 = and i1 %toBoolnot.i87, %tmp4.i90  ; <i1> [#uses=1]
  br i1 %or.cond173, label %bb4.i96, label %_ZN12...

Where it is "obvious" that when coming from %bb5.i117 that the 'and' is always 
false.  This triggers a surprisingly high number of times in the testsuite, 
and gets us closer to generating good code for doug's strswitch testcase.

This also make a bunch of other code in jump threading redundant, I'll rip
out in the next patch.  This survived an enable-checking llvm-gcc bootstrap.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86264 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-11-06 18:15:14 +00:00
parent 8d4e3b5b48
commit 785672534d
2 changed files with 356 additions and 27 deletions

View File

@@ -170,5 +170,36 @@ BB4:
}
;; This tests that the branch in 'merge' can be cloned up into T1.
;; rdar://7367025
define i32 @test7(i1 %cond, i1 %cond2) {
Entry:
; CHECK: @test7
%v1 = call i32 @f1()
br i1 %cond, label %Merge, label %F1
F1:
%v2 = call i32 @f2()
br label %Merge
Merge:
%B = phi i32 [%v1, %Entry], [%v2, %F1]
%M = icmp ne i32 %B, %v1
%N = icmp eq i32 %B, 47
%O = and i1 %M, %N
br i1 %O, label %T2, label %F2
; CHECK: Merge:
; CHECK-NOT: phi
; CHECK-NEXT: %v2 = call i32 @f2()
T2:
call void @f3()
ret i32 %B
F2:
ret i32 %B
; CHECK: F2:
; CHECK-NEXT: phi i32
}