2007-04-14 20:13:02 +00:00
|
|
|
; Test that this transform works:
|
2007-03-05 22:51:08 +00:00
|
|
|
; udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr X, C2)
|
|
|
|
;
|
2009-09-08 22:41:33 +00:00
|
|
|
; RUN: opt < %s -instcombine -S -o %t
|
Fix PR2506 by being a bit more careful about reverse fact propagation when
disproving a condition. This actually compiles the existing testcase
(udiv_select_to_select_shift) to:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%divisor1.t = lshr i64 %X, 3 ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %divisor1.t, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
instead of:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%quotient1.v = select i1 %Cond, i64 3, i64 4 ; <i64> [#uses=1]
%quotient1 = lshr i64 %X, %quotient1.v ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %quotient1, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:15:52 +00:00
|
|
|
; RUN: not grep select %t
|
2007-08-15 13:36:28 +00:00
|
|
|
; RUN: grep lshr %t | count 2
|
Fix PR2506 by being a bit more careful about reverse fact propagation when
disproving a condition. This actually compiles the existing testcase
(udiv_select_to_select_shift) to:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%divisor1.t = lshr i64 %X, 3 ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %divisor1.t, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
instead of:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%quotient1.v = select i1 %Cond, i64 3, i64 4 ; <i64> [#uses=1]
%quotient1 = lshr i64 %X, %quotient1.v ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %quotient1, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:15:52 +00:00
|
|
|
; RUN: not grep udiv %t
|
2007-03-05 22:51:08 +00:00
|
|
|
|
|
|
|
define i64 @test(i64 %X, i1 %Cond ) {
|
|
|
|
entry:
|
Fix PR2506 by being a bit more careful about reverse fact propagation when
disproving a condition. This actually compiles the existing testcase
(udiv_select_to_select_shift) to:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%divisor1.t = lshr i64 %X, 3 ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %divisor1.t, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
instead of:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%quotient1.v = select i1 %Cond, i64 3, i64 4 ; <i64> [#uses=1]
%quotient1 = lshr i64 %X, %quotient1.v ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %quotient1, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:15:52 +00:00
|
|
|
%divisor1 = select i1 %Cond, i64 16, i64 8
|
2007-03-05 22:51:08 +00:00
|
|
|
%quotient1 = udiv i64 %X, %divisor1
|
|
|
|
%divisor2 = select i1 %Cond, i64 8, i64 0
|
|
|
|
%quotient2 = udiv i64 %X, %divisor2
|
|
|
|
%sum = add i64 %quotient1, %quotient2
|
|
|
|
ret i64 %sum
|
|
|
|
}
|