Convert InstCombine tests from notcast to FileCheck.

llvm-svn: 83825
This commit is contained in:
Edward O'Callaghan 2009-10-12 06:14:06 +00:00
parent a3ed9edd40
commit 484b6c2cfc
5 changed files with 49 additions and 9 deletions

View File

@ -9,124 +9,152 @@
; be eliminated. In many cases the setCC is also eliminated based on the ; be eliminated. In many cases the setCC is also eliminated based on the
; constant value and the range of the casted value. ; constant value and the range of the casted value.
; ;
; RUN: opt < %s -instcombine -S | \ ; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: notcast .*int
; END. ; END.
define i1 @lt_signed_to_large_unsigned(i8 %SB) { define i1 @lt_signed_to_large_unsigned(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C1 = icmp sgt i8 %SB, -1
; CHECK: ret i1 %C1
} }
define i1 @lt_signed_to_large_signed(i8 %SB) { define i1 @lt_signed_to_large_signed(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp slt i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 true
} }
define i1 @lt_signed_to_large_negative(i8 %SB) { define i1 @lt_signed_to_large_negative(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, -1024 ; <i1> [#uses=1] %C = icmp slt i32 %Y, -1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 false
} }
define i1 @lt_signed_to_small_signed(i8 %SB) { define i1 @lt_signed_to_small_signed(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, 17 ; <i1> [#uses=1] %C = icmp slt i32 %Y, 17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp slt i8 %SB, 17
; CHECK: ret i1 %C
} }
define i1 @lt_signed_to_small_negative(i8 %SB) { define i1 @lt_signed_to_small_negative(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, -17 ; <i1> [#uses=1] %C = icmp slt i32 %Y, -17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp slt i8 %SB, -17
; CHECK: ret i1 %C
} }
define i1 @lt_unsigned_to_large_unsigned(i8 %SB) { define i1 @lt_unsigned_to_large_unsigned(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 true
} }
define i1 @lt_unsigned_to_large_signed(i8 %SB) { define i1 @lt_unsigned_to_large_signed(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp slt i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 true
} }
define i1 @lt_unsigned_to_large_negative(i8 %SB) { define i1 @lt_unsigned_to_large_negative(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, -1024 ; <i1> [#uses=1] %C = icmp slt i32 %Y, -1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 false
} }
define i1 @lt_unsigned_to_small_unsigned(i8 %SB) { define i1 @lt_unsigned_to_small_unsigned(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ult i32 %Y, 17 ; <i1> [#uses=1] %C = icmp ult i32 %Y, 17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp ult i8 %SB, 17
; CHECK: ret i1 %C
} }
define i1 @lt_unsigned_to_small_negative(i8 %SB) { define i1 @lt_unsigned_to_small_negative(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp slt i32 %Y, -17 ; <i1> [#uses=1] %C = icmp slt i32 %Y, -17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 false
} }
define i1 @gt_signed_to_large_unsigned(i8 %SB) { define i1 @gt_signed_to_large_unsigned(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ugt i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp ugt i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp slt i8 %SB, 0
; CHECK: ret i1 %C
} }
define i1 @gt_signed_to_large_signed(i8 %SB) { define i1 @gt_signed_to_large_signed(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 false
} }
define i1 @gt_signed_to_large_negative(i8 %SB) { define i1 @gt_signed_to_large_negative(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, -1024 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, -1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 true
} }
define i1 @gt_signed_to_small_signed(i8 %SB) { define i1 @gt_signed_to_small_signed(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, 17 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, 17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp sgt i8 %SB, 17
; CHECK: ret i1 %C
} }
define i1 @gt_signed_to_small_negative(i8 %SB) { define i1 @gt_signed_to_small_negative(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, -17 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, -17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp sgt i8 %SB, -17
; CHECK: ret i1 %C
} }
define i1 @gt_unsigned_to_large_unsigned(i8 %SB) { define i1 @gt_unsigned_to_large_unsigned(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ugt i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp ugt i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 false
} }
define i1 @gt_unsigned_to_large_signed(i8 %SB) { define i1 @gt_unsigned_to_large_signed(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, 1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 false
} }
define i1 @gt_unsigned_to_large_negative(i8 %SB) { define i1 @gt_unsigned_to_large_negative(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, -1024 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, -1024 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 true
} }
define i1 @gt_unsigned_to_small_unsigned(i8 %SB) { define i1 @gt_unsigned_to_small_unsigned(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ugt i32 %Y, 17 ; <i1> [#uses=1] %C = icmp ugt i32 %Y, 17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: %C = icmp ugt i8 %SB, 17
; CHECK: ret i1 %C
} }
define i1 @gt_unsigned_to_small_negative(i8 %SB) { define i1 @gt_unsigned_to_small_negative(i8 %SB) {
%Y = zext i8 %SB to i32 ; <i32> [#uses=1] %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp sgt i32 %Y, -17 ; <i1> [#uses=1] %C = icmp sgt i32 %Y, -17 ; <i1> [#uses=1]
ret i1 %C ret i1 %C
; CHECK: ret i1 true
} }

View File

@ -1,11 +1,13 @@
; RUN: opt < %s -instcombine -S | grep shl ; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: opt < %s -instcombine -S | notcast
; This cannot be turned into a sign extending cast! ; This cannot be turned into a sign extending cast!
define i64 @test(i64 %X) { define i64 @test(i64 %X) {
%Y = shl i64 %X, 16 ; <i64> [#uses=1] %Y = shl i64 %X, 16 ; <i64> [#uses=1]
; CHECK: %Y = shl i64 %X, 16
%Z = ashr i64 %Y, 16 ; <i64> [#uses=1] %Z = ashr i64 %Y, 16 ; <i64> [#uses=1]
; CHECK: %Z = ashr i64 %Y, 16
ret i64 %Z ret i64 %Z
; CHECK: ret i64 %Z
} }

View File

@ -1,5 +1,4 @@
; RUN: opt < %s -instcombine -S | notcast ; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: opt < %s -instcombine -S | not grep {icmp s}
; PR1940 ; PR1940
define i1 @test1(i8 %A, i8 %B) { define i1 @test1(i8 %A, i8 %B) {
@ -7,6 +6,8 @@ define i1 @test1(i8 %A, i8 %B) {
%b = zext i8 %B to i32 %b = zext i8 %B to i32
%c = icmp sgt i32 %a, %b %c = icmp sgt i32 %a, %b
ret i1 %c ret i1 %c
; CHECK: %c = icmp ugt i8 %A, %B
; CHECK: ret i1 %c
} }
define i1 @test2(i8 %A, i8 %B) { define i1 @test2(i8 %A, i8 %B) {
@ -14,4 +15,6 @@ define i1 @test2(i8 %A, i8 %B) {
%b = sext i8 %B to i32 %b = sext i8 %B to i32
%c = icmp ugt i32 %a, %b %c = icmp ugt i32 %a, %b
ret i1 %c ret i1 %c
; CHECK: %c = icmp ugt i8 %A, %B
; CHECK: ret i1 %c
} }

View File

@ -1,11 +1,15 @@
; RUN: opt < %s -instcombine -S | notcast ; RUN: opt < %s -instcombine -S | FileCheck %s
define i16 @test1(i16 %a) { define i16 @test1(i16 %a) {
%tmp = zext i16 %a to i32 ; <i32> [#uses=2] %tmp = zext i16 %a to i32 ; <i32> [#uses=2]
%tmp21 = lshr i32 %tmp, 8 ; <i32> [#uses=1] %tmp21 = lshr i32 %tmp, 8 ; <i32> [#uses=1]
; CHECK: %tmp21 = lshr i16 %a, 8
%tmp5 = mul i32 %tmp, 5 ; <i32> [#uses=1] %tmp5 = mul i32 %tmp, 5 ; <i32> [#uses=1]
; CHECK: %tmp5 = mul i16 %a, 5
%tmp.upgrd.32 = or i32 %tmp21, %tmp5 ; <i32> [#uses=1] %tmp.upgrd.32 = or i32 %tmp21, %tmp5 ; <i32> [#uses=1]
; CHECK: %tmp.upgrd.32 = or i16 %tmp21, %tmp5
%tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16 ; <i16> [#uses=1] %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16 ; <i16> [#uses=1]
ret i16 %tmp.upgrd.3 ret i16 %tmp.upgrd.3
; CHECK: ret i16 %tmp.upgrd.32
} }

View File

@ -1,11 +1,13 @@
; Tests to make sure elimination of casts is working correctly ; Tests to make sure elimination of casts is working correctly
; RUN: opt < %s -instcombine -S | \ ; RUN: opt < %s -instcombine -S | FileCheck %s
; RUN: notcast {} {%c1.*}
define i64 @test_sext_zext(i16 %A) { define i64 @test_sext_zext(i16 %A) {
%c1 = zext i16 %A to i32 ; <i32> [#uses=1] %c1 = zext i16 %A to i32 ; <i32> [#uses=1]
%c2 = sext i32 %c1 to i64 ; <i64> [#uses=1] %c2 = sext i32 %c1 to i64 ; <i64> [#uses=1]
ret i64 %c2 ret i64 %c2
CHECK-NOT: %c1
CHECK: %c2 = zext i16 %A to i64
CHECK: ret i64 %c2
} }
; PR3599 ; PR3599
@ -29,5 +31,6 @@ entry:
%tmp16 = or i32 %tmp15, %tmp6 ; <i32> [#uses=1] %tmp16 = or i32 %tmp15, %tmp6 ; <i32> [#uses=1]
%tmp17 = or i32 %tmp16, %tmp3 ; <i32> [#uses=1] %tmp17 = or i32 %tmp16, %tmp3 ; <i32> [#uses=1]
ret i32 %tmp17 ret i32 %tmp17
CHECK: ret i1 true
} }