forked from OSchip/llvm-project
[ConstFold] Salvage some div/rem folding test (NFC)
The div/rem constant expressions are going away in D129148. Convert some tests to use InstSimplify instead, to show that the constant folding still happens.
This commit is contained in:
parent
c2d1d9f942
commit
02b38ba8aa
|
@ -11,8 +11,6 @@
|
|||
@add = global i64* inttoptr (i64 add (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X + 0 == X
|
||||
@sub = global i64* inttoptr (i64 sub (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X - 0 == X
|
||||
@mul = global i64* inttoptr (i64 mul (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X * 0 == 0
|
||||
@sdiv = global i64* inttoptr (i64 sdiv (i64 ptrtoint (i64* @A to i64), i64 1) to i64*) ; X / 1 == X
|
||||
@srem = global i64* inttoptr (i64 srem (i64 ptrtoint (i64* @A to i64), i64 1) to i64*) ; X % 1 == 0
|
||||
@and1 = global i64* inttoptr (i64 and (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X & 0 == 0
|
||||
@and2 = global i64* inttoptr (i64 and (i64 ptrtoint (i64* @A to i64), i64 -1) to i64*) ; X & -1 == X
|
||||
@or = global i64 or (i64 ptrtoint (i64* @A to i64), i64 -1) ; X | -1 == -1
|
||||
|
@ -44,8 +42,6 @@
|
|||
; CHECK: @[[ADD:[a-zA-Z0-9_$"\\.-]+]] = global i64* @A
|
||||
; CHECK: @[[SUB:[a-zA-Z0-9_$"\\.-]+]] = global i64* @A
|
||||
; CHECK: @[[MUL:[a-zA-Z0-9_$"\\.-]+]] = global i64* null
|
||||
; CHECK: @[[SDIV:[a-zA-Z0-9_$"\\.-]+]] = global i64* @A
|
||||
; CHECK: @[[SREM:[a-zA-Z0-9_$"\\.-]+]] = global i64* null
|
||||
; CHECK: @[[AND1:[a-zA-Z0-9_$"\\.-]+]] = global i64* null
|
||||
; CHECK: @[[AND2:[a-zA-Z0-9_$"\\.-]+]] = global i64* @A
|
||||
; CHECK: @[[OR:[a-zA-Z0-9_$"\\.-]+]] = global i64 -1
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
; RUN: llvm-as < %s | llvm-dis | grep "global i32 0"
|
||||
; PR1215
|
||||
|
||||
@G = global i32 sdiv (i32 0, i32 -1)
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
; RUN: llvm-as < %s | llvm-dis | not grep ptrtoint
|
||||
; PR4424
|
||||
@G = external global i32
|
||||
@test1 = constant i32 sdiv (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
@test2 = constant i32 udiv (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
@test3 = constant i32 srem (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
@test4 = constant i32 urem (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
@test5 = constant i32 lshr (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
@test6 = constant i32 ashr (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
@test7 = constant i32 shl (i32 0, i32 ptrtoint (ptr @G to i32))
|
||||
|
|
|
@ -11,15 +11,6 @@
|
|||
@C = global i1 mul (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
|
||||
; CHECK: @C = global i1 and (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
|
||||
|
||||
@D = global i1 sdiv (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
|
||||
; CHECK: @D = global i1 icmp ult (ptr @X, ptr @Y)
|
||||
@E = global i1 udiv (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
|
||||
; CHECK: @E = global i1 icmp ult (ptr @X, ptr @Y)
|
||||
@F = global i1 srem (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
|
||||
; CHECK: @F = global i1 false
|
||||
@G = global i1 urem (i1 icmp ult (ptr @X, ptr @Y), i1 icmp ult (ptr @X, ptr @Z))
|
||||
; CHECK: @G = global i1 false
|
||||
|
||||
@H = global i1 icmp ule (ptr @X, ptr @Y)
|
||||
; CHECK: @H = global i1 icmp ule (ptr @X, ptr @Y)
|
||||
|
||||
|
|
|
@ -226,4 +226,112 @@ define i8 @sdiv_minusone_divisor() {
|
|||
ret i8 %v
|
||||
}
|
||||
|
||||
@g = external global i64
|
||||
@g2 = external global i64
|
||||
|
||||
define i64 @const_sdiv_one() {
|
||||
; CHECK-LABEL: @const_sdiv_one(
|
||||
; CHECK-NEXT: ret i64 ptrtoint (ptr @g to i64)
|
||||
;
|
||||
%div = sdiv i64 ptrtoint (ptr @g to i64), 1
|
||||
ret i64 %div
|
||||
}
|
||||
|
||||
define i64 @const_srem_one() {
|
||||
; CHECK-LABEL: @const_srem_one(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%rem = srem i64 ptrtoint (ptr @g to i64), 1
|
||||
ret i64 %rem
|
||||
}
|
||||
|
||||
define i64 @const_udiv_one() {
|
||||
; CHECK-LABEL: @const_udiv_one(
|
||||
; CHECK-NEXT: ret i64 ptrtoint (ptr @g to i64)
|
||||
;
|
||||
%div = udiv i64 ptrtoint (ptr @g to i64), 1
|
||||
ret i64 %div
|
||||
}
|
||||
|
||||
define i64 @const_urem_one() {
|
||||
; CHECK-LABEL: @const_urem_one(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%rem = urem i64 ptrtoint (ptr @g to i64), 1
|
||||
ret i64 %rem
|
||||
}
|
||||
|
||||
define i64 @const_sdiv_zero() {
|
||||
; CHECK-LABEL: @const_sdiv_zero(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%div = sdiv i64 0, ptrtoint (ptr @g to i64)
|
||||
ret i64 %div
|
||||
}
|
||||
|
||||
define i64 @const_srem_zero() {
|
||||
; CHECK-LABEL: @const_srem_zero(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%rem = srem i64 0, ptrtoint (ptr @g to i64)
|
||||
ret i64 %rem
|
||||
}
|
||||
|
||||
define i64 @const_udiv_zero() {
|
||||
; CHECK-LABEL: @const_udiv_zero(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%div = udiv i64 0, ptrtoint (ptr @g to i64)
|
||||
ret i64 %div
|
||||
}
|
||||
|
||||
define i64 @const_urem_zero() {
|
||||
; CHECK-LABEL: @const_urem_zero(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%rem = urem i64 0, ptrtoint (ptr @g to i64)
|
||||
ret i64 %rem
|
||||
}
|
||||
|
||||
define i64 @const_sdiv_zero_negone() {
|
||||
; CHECK-LABEL: @const_sdiv_zero_negone(
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%div = sdiv i64 0, -1
|
||||
ret i64 %div
|
||||
}
|
||||
|
||||
define i1 @const_sdiv_i1() {
|
||||
; CHECK-LABEL: @const_sdiv_i1(
|
||||
; CHECK-NEXT: ret i1 ptrtoint (ptr @g to i1)
|
||||
;
|
||||
%div = sdiv i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
|
||||
ret i1 %div
|
||||
}
|
||||
|
||||
define i1 @const_srem_1() {
|
||||
; CHECK-LABEL: @const_srem_1(
|
||||
; CHECK-NEXT: ret i1 false
|
||||
;
|
||||
%rem = srem i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
|
||||
ret i1 %rem
|
||||
}
|
||||
|
||||
define i1 @const_udiv_i1() {
|
||||
; CHECK-LABEL: @const_udiv_i1(
|
||||
; CHECK-NEXT: ret i1 ptrtoint (ptr @g to i1)
|
||||
;
|
||||
%div = udiv i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
|
||||
ret i1 %div
|
||||
}
|
||||
|
||||
define i1 @const_urem_1() {
|
||||
; CHECK-LABEL: @const_urem_1(
|
||||
; CHECK-NEXT: ret i1 false
|
||||
;
|
||||
%rem = urem i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
|
||||
ret i1 %rem
|
||||
}
|
||||
|
||||
|
||||
!0 = !{i32 0, i32 3}
|
||||
|
|
Loading…
Reference in New Issue