mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
c6219bad2e
consider: (and (icmp X, Y), (and Z, (icmp A, B))) It may be possible to combine (icmp X, Y) with (icmp A, B). If we successfully combine, create an 'and' instruction with Z. This fixes PR20814. N.B. There is room for improvement after this change but I'm not convinced it's worth chasing yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216814 91177308-0d34-0410-b5e6-96231b3b80d8
69 lines
1.6 KiB
LLVM
69 lines
1.6 KiB
LLVM
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
; PR1738
|
|
define i1 @test1(double %X, double %Y) {
|
|
%tmp9 = fcmp ord double %X, 0.000000e+00
|
|
%tmp13 = fcmp ord double %Y, 0.000000e+00
|
|
%bothcond = and i1 %tmp13, %tmp9
|
|
ret i1 %bothcond
|
|
; CHECK: fcmp ord double %Y, %X
|
|
}
|
|
|
|
define i1 @test2(i1 %X, i1 %Y) {
|
|
%a = and i1 %X, %Y
|
|
%b = and i1 %a, %X
|
|
ret i1 %b
|
|
; CHECK-LABEL: @test2(
|
|
; CHECK-NEXT: and i1 %X, %Y
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define i32 @test3(i32 %X, i32 %Y) {
|
|
%a = and i32 %X, %Y
|
|
%b = and i32 %Y, %a
|
|
ret i32 %b
|
|
; CHECK-LABEL: @test3(
|
|
; CHECK-NEXT: and i32 %X, %Y
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define i1 @test4(i32 %X) {
|
|
%a = icmp ult i32 %X, 31
|
|
%b = icmp slt i32 %X, 0
|
|
%c = and i1 %a, %b
|
|
ret i1 %c
|
|
; CHECK-LABEL: @test4(
|
|
; CHECK-NEXT: ret i1 false
|
|
}
|
|
|
|
; Make sure we don't go into an infinite loop with this test
|
|
define <4 x i32> @test5(<4 x i32> %A) {
|
|
%1 = xor <4 x i32> %A, <i32 1, i32 2, i32 3, i32 4>
|
|
%2 = and <4 x i32> <i32 1, i32 2, i32 3, i32 4>, %1
|
|
ret <4 x i32> %2
|
|
}
|
|
|
|
; Check that we combine "if x!=0 && x!=-1" into "if x+1u>1"
|
|
define i32 @test6(i64 %x) nounwind {
|
|
; CHECK-LABEL: @test6(
|
|
; CHECK-NEXT: add i64 %x, 1
|
|
; CHECK-NEXT: icmp ugt i64 %x.off, 1
|
|
%cmp1 = icmp ne i64 %x, -1
|
|
%not.cmp = icmp ne i64 %x, 0
|
|
%.cmp1 = and i1 %cmp1, %not.cmp
|
|
%land.ext = zext i1 %.cmp1 to i32
|
|
ret i32 %land.ext
|
|
}
|
|
|
|
define i1 @test7(i32 %i, i1 %b) {
|
|
; CHECK-LABEL: @test7(
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %i, 0
|
|
; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP]], %b
|
|
; CHECK-NEXT: ret i1 [[AND]]
|
|
%cmp1 = icmp slt i32 %i, 1
|
|
%cmp2 = icmp sgt i32 %i, -1
|
|
%and1 = and i1 %cmp1, %b
|
|
%and2 = and i1 %and1, %cmp2
|
|
ret i1 %and2
|
|
}
|