2009-12-21 03:11:05 +00:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2007-04-11 06:52:24 +00:00
|
|
|
|
2014-06-09 19:20:29 +00:00
|
|
|
target datalayout = "e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
|
2011-02-10 07:11:16 +00:00
|
|
|
|
2007-04-11 06:52:24 +00:00
|
|
|
define i32 @test1(i32 %X) {
|
|
|
|
entry:
|
|
|
|
icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
|
|
|
|
zext i1 %0 to i32 ; <i32>:1 [#uses=1]
|
|
|
|
ret i32 %1
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test1(
|
2009-12-21 03:11:05 +00:00
|
|
|
; CHECK: lshr i32 %X, 31
|
|
|
|
; CHECK-NEXT: ret i32
|
2007-04-11 06:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test2(i32 %X) {
|
|
|
|
entry:
|
|
|
|
icmp ult i32 %X, -2147483648 ; <i1>:0 [#uses=1]
|
|
|
|
zext i1 %0 to i32 ; <i32>:1 [#uses=1]
|
|
|
|
ret i32 %1
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test2(
|
2009-12-21 03:11:05 +00:00
|
|
|
; CHECK: lshr i32 %X, 31
|
|
|
|
; CHECK-NEXT: xor i32
|
|
|
|
; CHECK-NEXT: ret i32
|
2007-04-11 06:52:24 +00:00
|
|
|
}
|
|
|
|
|
2007-04-11 06:57:54 +00:00
|
|
|
define i32 @test3(i32 %X) {
|
|
|
|
entry:
|
|
|
|
icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
|
|
|
|
sext i1 %0 to i32 ; <i32>:1 [#uses=1]
|
|
|
|
ret i32 %1
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test3(
|
2009-12-21 03:11:05 +00:00
|
|
|
; CHECK: ashr i32 %X, 31
|
|
|
|
; CHECK-NEXT: ret i32
|
2007-04-11 06:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test4(i32 %X) {
|
|
|
|
entry:
|
|
|
|
icmp ult i32 %X, -2147483648 ; <i1>:0 [#uses=1]
|
|
|
|
sext i1 %0 to i32 ; <i32>:1 [#uses=1]
|
|
|
|
ret i32 %1
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test4(
|
2009-12-21 03:11:05 +00:00
|
|
|
; CHECK: ashr i32 %X, 31
|
|
|
|
; CHECK-NEXT: xor i32
|
|
|
|
; CHECK-NEXT: ret i32
|
2007-04-11 06:57:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 05:12:37 +00:00
|
|
|
; PR4837
|
|
|
|
define <2 x i1> @test5(<2 x i64> %x) {
|
|
|
|
entry:
|
|
|
|
%V = icmp eq <2 x i64> %x, undef
|
|
|
|
ret <2 x i1> %V
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test5(
|
2010-03-03 19:46:03 +00:00
|
|
|
; CHECK: ret <2 x i1> <i1 true, i1 true>
|
2009-10-11 21:22:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test6(i32 %a, i32 %b) {
|
|
|
|
%c = icmp sle i32 %a, -1
|
|
|
|
%d = zext i1 %c to i32
|
|
|
|
%e = sub i32 0, %d
|
|
|
|
%f = and i32 %e, %b
|
|
|
|
ret i32 %f
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test6(
|
2009-12-21 03:11:05 +00:00
|
|
|
; CHECK-NEXT: ashr i32 %a, 31
|
|
|
|
; CHECK-NEXT: %f = and i32 %e, %b
|
|
|
|
; CHECK-NEXT: ret i32 %f
|
2009-10-11 21:22:21 +00:00
|
|
|
}
|
2009-12-21 03:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
define i1 @test7(i32 %x) {
|
|
|
|
entry:
|
|
|
|
%a = add i32 %x, -1
|
|
|
|
%b = icmp ult i32 %a, %x
|
|
|
|
ret i1 %b
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test7(
|
2009-12-21 03:19:28 +00:00
|
|
|
; CHECK: %b = icmp ne i32 %x, 0
|
|
|
|
; CHECK: ret i1 %b
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test8(i32 %x){
|
|
|
|
entry:
|
2013-08-21 19:53:10 +00:00
|
|
|
%a = add i32 %x, -1
|
2009-12-21 03:19:28 +00:00
|
|
|
%b = icmp eq i32 %a, %x
|
|
|
|
ret i1 %b
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test8(
|
2009-12-21 03:19:28 +00:00
|
|
|
; CHECK: ret i1 false
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test9(i32 %x) {
|
|
|
|
entry:
|
|
|
|
%a = add i32 %x, -2
|
2013-08-21 19:53:10 +00:00
|
|
|
%b = icmp ugt i32 %x, %a
|
2009-12-21 03:19:28 +00:00
|
|
|
ret i1 %b
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test9(
|
2009-12-21 03:19:28 +00:00
|
|
|
; CHECK: icmp ugt i32 %x, 1
|
|
|
|
; CHECK: ret i1 %b
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test10(i32 %x){
|
|
|
|
entry:
|
2013-08-21 19:53:10 +00:00
|
|
|
%a = add i32 %x, -1
|
|
|
|
%b = icmp slt i32 %a, %x
|
2009-12-21 03:19:28 +00:00
|
|
|
ret i1 %b
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test10(
|
2009-12-21 03:19:28 +00:00
|
|
|
; CHECK: %b = icmp ne i32 %x, -2147483648
|
|
|
|
; CHECK: ret i1 %b
|
|
|
|
}
|
2009-12-21 04:04:05 +00:00
|
|
|
|
|
|
|
define i1 @test11(i32 %x) {
|
|
|
|
%a = add nsw i32 %x, 8
|
|
|
|
%b = icmp slt i32 %x, %a
|
|
|
|
ret i1 %b
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test11(
|
2009-12-21 04:04:05 +00:00
|
|
|
; CHECK: ret i1 true
|
|
|
|
}
|
|
|
|
|
2010-02-01 20:04:40 +00:00
|
|
|
; PR6195
|
|
|
|
define i1 @test12(i1 %A) {
|
|
|
|
%S = select i1 %A, i64 -4294967295, i64 8589934591
|
|
|
|
%B = icmp ne i64 bitcast (<2 x i32> <i32 1, i32 -1> to i64), %S
|
|
|
|
ret i1 %B
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test12(
|
2012-01-27 23:33:07 +00:00
|
|
|
; CHECK-NEXT: = xor i1 %A, true
|
|
|
|
; CHECK-NEXT: ret i1
|
2010-02-01 20:04:40 +00:00
|
|
|
}
|
2010-03-03 19:46:03 +00:00
|
|
|
|
|
|
|
; PR6481
|
|
|
|
define i1 @test13(i8 %X) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp slt i8 undef, %X
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test13(
|
2010-03-03 19:46:03 +00:00
|
|
|
; CHECK: ret i1 false
|
|
|
|
}
|
|
|
|
|
2010-06-28 21:30:07 +00:00
|
|
|
define i1 @test14(i8 %X) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp slt i8 undef, -128
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test14(
|
2010-06-28 21:30:07 +00:00
|
|
|
; CHECK: ret i1 false
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test15() nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp eq i8 undef, -128
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test15(
|
2010-06-28 21:30:07 +00:00
|
|
|
; CHECK: ret i1 undef
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test16() nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ne i8 undef, -128
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test16(
|
2010-06-28 21:30:07 +00:00
|
|
|
; CHECK: ret i1 undef
|
|
|
|
}
|
2010-11-21 06:44:42 +00:00
|
|
|
|
|
|
|
define i1 @test17(i32 %x) nounwind {
|
|
|
|
%shl = shl i32 1, %x
|
|
|
|
%and = and i32 %shl, 8
|
|
|
|
%cmp = icmp eq i32 %and, 0
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test17(
|
2010-11-23 02:42:04 +00:00
|
|
|
; CHECK-NEXT: %cmp = icmp ne i32 %x, 3
|
2010-11-21 06:44:42 +00:00
|
|
|
}
|
|
|
|
|
2014-06-02 07:57:24 +00:00
|
|
|
define i1 @test17a(i32 %x) nounwind {
|
|
|
|
%shl = shl i32 1, %x
|
|
|
|
%and = and i32 %shl, 7
|
|
|
|
%cmp = icmp eq i32 %and, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK-LABEL: @test17a(
|
|
|
|
; CHECK-NEXT: %cmp = icmp ugt i32 %x, 2
|
|
|
|
}
|
2010-11-21 06:44:42 +00:00
|
|
|
|
|
|
|
define i1 @test18(i32 %x) nounwind {
|
|
|
|
%sh = lshr i32 8, %x
|
|
|
|
%and = and i32 %sh, 1
|
|
|
|
%cmp = icmp eq i32 %and, 0
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test18(
|
2010-11-23 02:42:04 +00:00
|
|
|
; CHECK-NEXT: %cmp = icmp ne i32 %x, 3
|
2010-11-21 06:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test19(i32 %x) nounwind {
|
|
|
|
%shl = shl i32 1, %x
|
|
|
|
%and = and i32 %shl, 8
|
|
|
|
%cmp = icmp eq i32 %and, 8
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test19(
|
2010-11-23 02:42:04 +00:00
|
|
|
; CHECK-NEXT: %cmp = icmp eq i32 %x, 3
|
2010-11-21 06:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test20(i32 %x) nounwind {
|
|
|
|
%shl = shl i32 1, %x
|
|
|
|
%and = and i32 %shl, 8
|
|
|
|
%cmp = icmp ne i32 %and, 0
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test20(
|
2010-11-23 02:42:04 +00:00
|
|
|
; CHECK-NEXT: %cmp = icmp eq i32 %x, 3
|
2010-11-21 06:44:42 +00:00
|
|
|
}
|
|
|
|
|
2014-06-02 07:57:24 +00:00
|
|
|
define i1 @test20a(i32 %x) nounwind {
|
|
|
|
%shl = shl i32 1, %x
|
|
|
|
%and = and i32 %shl, 7
|
|
|
|
%cmp = icmp ne i32 %and, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK-LABEL: @test20a(
|
|
|
|
; CHECK-NEXT: %cmp = icmp ult i32 %x, 3
|
|
|
|
}
|
|
|
|
|
2011-01-11 00:36:45 +00:00
|
|
|
define i1 @test21(i8 %x, i8 %y) {
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test21(
|
2011-01-11 00:36:45 +00:00
|
|
|
; CHECK-NOT: or i8
|
|
|
|
; CHECK: icmp ugt
|
|
|
|
%A = or i8 %x, 1
|
|
|
|
%B = icmp ugt i8 %A, 3
|
|
|
|
ret i1 %B
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test22(i8 %x, i8 %y) {
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test22(
|
2011-01-11 00:36:45 +00:00
|
|
|
; CHECK-NOT: or i8
|
|
|
|
; CHECK: icmp ult
|
|
|
|
%A = or i8 %x, 1
|
|
|
|
%B = icmp ult i8 %A, 4
|
|
|
|
ret i1 %B
|
|
|
|
}
|
2011-02-09 17:06:41 +00:00
|
|
|
|
|
|
|
; PR2740
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test23(
|
2011-02-09 17:06:41 +00:00
|
|
|
; CHECK: icmp sgt i32 %x, 1328634634
|
|
|
|
define i1 @test23(i32 %x) nounwind {
|
|
|
|
%i3 = sdiv i32 %x, -1328634635
|
|
|
|
%i4 = icmp eq i32 %i3, -1
|
|
|
|
ret i1 %i4
|
|
|
|
}
|
2011-02-10 07:11:16 +00:00
|
|
|
|
|
|
|
@X = global [1000 x i32] zeroinitializer
|
|
|
|
|
|
|
|
; PR8882
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test24(
|
2011-02-10 07:11:16 +00:00
|
|
|
; CHECK: %cmp = icmp eq i64 %i, 1000
|
|
|
|
; CHECK: ret i1 %cmp
|
|
|
|
define i1 @test24(i64 %i) {
|
2015-03-13 18:20:45 +00:00
|
|
|
%p1 = getelementptr inbounds i32, i32* getelementptr inbounds ([1000 x i32], [1000 x i32]* @X, i64 0, i64 0), i64 %i
|
|
|
|
%cmp = icmp eq i32* %p1, getelementptr inbounds ([1000 x i32], [1000 x i32]* @X, i64 1, i64 0)
|
2011-02-10 07:11:16 +00:00
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-08-21 19:53:10 +00:00
|
|
|
@X_as1 = addrspace(1) global [1000 x i32] zeroinitializer
|
|
|
|
|
|
|
|
; CHECK: @test24_as1
|
|
|
|
; CHECK: trunc i64 %i to i16
|
|
|
|
; CHECK: %cmp = icmp eq i16 %1, 1000
|
|
|
|
; CHECK: ret i1 %cmp
|
|
|
|
define i1 @test24_as1(i64 %i) {
|
2015-03-13 18:20:45 +00:00
|
|
|
%p1 = getelementptr inbounds i32, i32 addrspace(1)* getelementptr inbounds ([1000 x i32], [1000 x i32] addrspace(1)* @X_as1, i64 0, i64 0), i64 %i
|
|
|
|
%cmp = icmp eq i32 addrspace(1)* %p1, getelementptr inbounds ([1000 x i32], [1000 x i32] addrspace(1)* @X_as1, i64 1, i64 0)
|
2013-08-21 19:53:10 +00:00
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test25(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X + Z > Y + Z -> X > Y if there is no overflow.
|
2011-02-17 07:46:37 +00:00
|
|
|
; CHECK: %c = icmp sgt i32 %x, %y
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test25(i32 %x, i32 %y, i32 %z) {
|
|
|
|
%lhs = add nsw i32 %x, %z
|
|
|
|
%rhs = add nsw i32 %y, %z
|
|
|
|
%c = icmp sgt i32 %lhs, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test26(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X + Z > Y + Z -> X > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp ugt i32 %x, %y
|
2011-02-17 07:46:37 +00:00
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test26(i32 %x, i32 %y, i32 %z) {
|
2011-02-18 16:25:37 +00:00
|
|
|
%lhs = add nuw i32 %x, %z
|
|
|
|
%rhs = add nuw i32 %y, %z
|
|
|
|
%c = icmp ugt i32 %lhs, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test27(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X - Z > Y - Z -> X > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp sgt i32 %x, %y
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test27(i32 %x, i32 %y, i32 %z) {
|
2011-02-17 07:46:37 +00:00
|
|
|
%lhs = sub nsw i32 %x, %z
|
|
|
|
%rhs = sub nsw i32 %y, %z
|
|
|
|
%c = icmp sgt i32 %lhs, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
2011-02-18 16:25:37 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test28(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X - Z > Y - Z -> X > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp ugt i32 %x, %y
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test28(i32 %x, i32 %y, i32 %z) {
|
|
|
|
%lhs = sub nuw i32 %x, %z
|
|
|
|
%rhs = sub nuw i32 %y, %z
|
|
|
|
%c = icmp ugt i32 %lhs, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test29(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X + Y > X -> Y > 0 if there is no overflow.
|
|
|
|
; CHECK: %c = icmp sgt i32 %y, 0
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test29(i32 %x, i32 %y) {
|
|
|
|
%lhs = add nsw i32 %x, %y
|
|
|
|
%c = icmp sgt i32 %lhs, %x
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test30(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X + Y > X -> Y > 0 if there is no overflow.
|
|
|
|
; CHECK: %c = icmp ne i32 %y, 0
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test30(i32 %x, i32 %y) {
|
|
|
|
%lhs = add nuw i32 %x, %y
|
|
|
|
%c = icmp ugt i32 %lhs, %x
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test31(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X > X + Y -> 0 > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp slt i32 %y, 0
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test31(i32 %x, i32 %y) {
|
|
|
|
%rhs = add nsw i32 %x, %y
|
|
|
|
%c = icmp sgt i32 %x, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test32(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X > X + Y -> 0 > Y if there is no overflow.
|
|
|
|
; CHECK: ret i1 false
|
|
|
|
define i1 @test32(i32 %x, i32 %y) {
|
|
|
|
%rhs = add nuw i32 %x, %y
|
|
|
|
%c = icmp ugt i32 %x, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test33(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X - Y > X -> 0 > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp slt i32 %y, 0
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test33(i32 %x, i32 %y) {
|
|
|
|
%lhs = sub nsw i32 %x, %y
|
|
|
|
%c = icmp sgt i32 %lhs, %x
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test34(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X - Y > X -> 0 > Y if there is no overflow.
|
|
|
|
; CHECK: ret i1 false
|
|
|
|
define i1 @test34(i32 %x, i32 %y) {
|
|
|
|
%lhs = sub nuw i32 %x, %y
|
|
|
|
%c = icmp ugt i32 %lhs, %x
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test35(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X > X - Y -> Y > 0 if there is no overflow.
|
|
|
|
; CHECK: %c = icmp sgt i32 %y, 0
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test35(i32 %x, i32 %y) {
|
|
|
|
%rhs = sub nsw i32 %x, %y
|
|
|
|
%c = icmp sgt i32 %x, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test36(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X > X - Y -> Y > 0 if there is no overflow.
|
|
|
|
; CHECK: %c = icmp ne i32 %y, 0
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test36(i32 %x, i32 %y) {
|
|
|
|
%rhs = sub nuw i32 %x, %y
|
|
|
|
%c = icmp ugt i32 %x, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test37(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X - Y > X - Z -> Z > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp sgt i32 %z, %y
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test37(i32 %x, i32 %y, i32 %z) {
|
|
|
|
%lhs = sub nsw i32 %x, %y
|
|
|
|
%rhs = sub nsw i32 %x, %z
|
|
|
|
%c = icmp sgt i32 %lhs, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test38(
|
2011-02-18 16:25:37 +00:00
|
|
|
; X - Y > X - Z -> Z > Y if there is no overflow.
|
|
|
|
; CHECK: %c = icmp ugt i32 %z, %y
|
|
|
|
; CHECK: ret i1 %c
|
|
|
|
define i1 @test38(i32 %x, i32 %y, i32 %z) {
|
|
|
|
%lhs = sub nuw i32 %x, %y
|
|
|
|
%rhs = sub nuw i32 %x, %z
|
|
|
|
%c = icmp ugt i32 %lhs, %rhs
|
|
|
|
ret i1 %c
|
|
|
|
}
|
2011-02-28 06:20:05 +00:00
|
|
|
|
2011-02-28 08:31:40 +00:00
|
|
|
; PR9343 #1
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test39(
|
2011-03-09 22:07:31 +00:00
|
|
|
; CHECK: %B = icmp eq i32 %X, 0
|
2011-02-28 09:17:39 +00:00
|
|
|
define i1 @test39(i32 %X, i32 %Y) {
|
2011-02-28 08:31:40 +00:00
|
|
|
%A = ashr exact i32 %X, %Y
|
|
|
|
%B = icmp eq i32 %A, 0
|
|
|
|
ret i1 %B
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test40(
|
2011-02-28 09:17:39 +00:00
|
|
|
; CHECK: %B = icmp ne i32 %X, 0
|
|
|
|
define i1 @test40(i32 %X, i32 %Y) {
|
2011-02-28 08:31:40 +00:00
|
|
|
%A = lshr exact i32 %X, %Y
|
|
|
|
%B = icmp ne i32 %A, 0
|
|
|
|
ret i1 %B
|
|
|
|
}
|
2011-03-04 10:06:52 +00:00
|
|
|
|
|
|
|
; PR9343 #3
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test41(
|
2011-03-04 10:06:52 +00:00
|
|
|
; CHECK: ret i1 true
|
|
|
|
define i1 @test41(i32 %X, i32 %Y) {
|
|
|
|
%A = urem i32 %X, %Y
|
|
|
|
%B = icmp ugt i32 %Y, %A
|
|
|
|
ret i1 %B
|
|
|
|
}
|
2011-03-05 04:28:48 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test42(
|
2011-03-05 04:28:48 +00:00
|
|
|
; CHECK: %B = icmp sgt i32 %Y, -1
|
|
|
|
define i1 @test42(i32 %X, i32 %Y) {
|
|
|
|
%A = srem i32 %X, %Y
|
|
|
|
%B = icmp slt i32 %A, %Y
|
|
|
|
ret i1 %B
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test43(
|
2011-03-05 04:28:48 +00:00
|
|
|
; CHECK: %B = icmp slt i32 %Y, 0
|
|
|
|
define i1 @test43(i32 %X, i32 %Y) {
|
|
|
|
%A = srem i32 %X, %Y
|
|
|
|
%B = icmp slt i32 %Y, %A
|
|
|
|
ret i1 %B
|
|
|
|
}
|
2011-03-05 05:19:11 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test44(
|
2011-03-05 05:19:11 +00:00
|
|
|
; CHECK: %B = icmp sgt i32 %Y, -1
|
|
|
|
define i1 @test44(i32 %X, i32 %Y) {
|
|
|
|
%A = srem i32 %X, %Y
|
|
|
|
%B = icmp slt i32 %A, %Y
|
|
|
|
ret i1 %B
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test45(
|
2011-03-05 05:19:11 +00:00
|
|
|
; CHECK: %B = icmp slt i32 %Y, 0
|
|
|
|
define i1 @test45(i32 %X, i32 %Y) {
|
|
|
|
%A = srem i32 %X, %Y
|
|
|
|
%B = icmp slt i32 %Y, %A
|
|
|
|
ret i1 %B
|
|
|
|
}
|
|
|
|
|
|
|
|
; PR9343 #4
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test46(
|
2011-03-05 05:19:11 +00:00
|
|
|
; CHECK: %C = icmp ult i32 %X, %Y
|
|
|
|
define i1 @test46(i32 %X, i32 %Y, i32 %Z) {
|
|
|
|
%A = ashr exact i32 %X, %Z
|
|
|
|
%B = ashr exact i32 %Y, %Z
|
|
|
|
%C = icmp ult i32 %A, %B
|
|
|
|
ret i1 %C
|
|
|
|
}
|
|
|
|
|
|
|
|
; PR9343 #5
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test47(
|
2011-03-05 05:19:11 +00:00
|
|
|
; CHECK: %C = icmp ugt i32 %X, %Y
|
|
|
|
define i1 @test47(i32 %X, i32 %Y, i32 %Z) {
|
|
|
|
%A = ashr exact i32 %X, %Z
|
|
|
|
%B = ashr exact i32 %Y, %Z
|
|
|
|
%C = icmp ugt i32 %A, %B
|
|
|
|
ret i1 %C
|
|
|
|
}
|
|
|
|
|
|
|
|
; PR9343 #8
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test48(
|
2011-03-05 05:19:11 +00:00
|
|
|
; CHECK: %C = icmp eq i32 %X, %Y
|
|
|
|
define i1 @test48(i32 %X, i32 %Y, i32 %Z) {
|
|
|
|
%A = sdiv exact i32 %X, %Z
|
|
|
|
%B = sdiv exact i32 %Y, %Z
|
|
|
|
%C = icmp eq i32 %A, %B
|
|
|
|
ret i1 %C
|
|
|
|
}
|
2011-03-06 03:36:19 +00:00
|
|
|
|
|
|
|
; PR8469
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test49(
|
2011-03-06 03:36:19 +00:00
|
|
|
; CHECK: ret <2 x i1> <i1 true, i1 true>
|
|
|
|
define <2 x i1> @test49(<2 x i32> %tmp3) {
|
|
|
|
entry:
|
|
|
|
%tmp11 = and <2 x i32> %tmp3, <i32 3, i32 3>
|
|
|
|
%cmp = icmp ult <2 x i32> %tmp11, <i32 4, i32 4>
|
2013-08-21 19:53:10 +00:00
|
|
|
ret <2 x i1> %cmp
|
2011-03-06 03:36:19 +00:00
|
|
|
}
|
2011-03-07 01:50:10 +00:00
|
|
|
|
|
|
|
; PR9343 #7
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test50(
|
2011-03-07 01:50:10 +00:00
|
|
|
; CHECK: ret i1 true
|
|
|
|
define i1 @test50(i16 %X, i32 %Y) {
|
|
|
|
%A = zext i16 %X to i32
|
|
|
|
%B = srem i32 %A, %Y
|
|
|
|
%C = icmp sgt i32 %B, -1
|
|
|
|
ret i1 %C
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test51(
|
2011-03-07 01:50:10 +00:00
|
|
|
; CHECK: ret i1 %C
|
2011-03-07 02:10:18 +00:00
|
|
|
define i1 @test51(i32 %X, i32 %Y) {
|
|
|
|
%A = and i32 %X, 2147483648
|
2011-03-07 01:50:10 +00:00
|
|
|
%B = srem i32 %A, %Y
|
|
|
|
%C = icmp sgt i32 %B, -1
|
|
|
|
ret i1 %C
|
|
|
|
}
|
2011-04-26 20:18:20 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test52(
|
2011-04-26 20:18:20 +00:00
|
|
|
; CHECK-NEXT: and i32 %x1, 16711935
|
|
|
|
; CHECK-NEXT: icmp eq i32 {{.*}}, 4980863
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
define i1 @test52(i32 %x1) nounwind {
|
|
|
|
%conv = and i32 %x1, 255
|
|
|
|
%cmp = icmp eq i32 %conv, 127
|
|
|
|
%tmp2 = lshr i32 %x1, 16
|
|
|
|
%tmp3 = trunc i32 %tmp2 to i8
|
|
|
|
%cmp15 = icmp eq i8 %tmp3, 76
|
|
|
|
|
|
|
|
%A = and i1 %cmp, %cmp15
|
|
|
|
ret i1 %A
|
|
|
|
}
|
|
|
|
|
2011-05-05 21:59:18 +00:00
|
|
|
; PR9838
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test53(
|
2013-11-16 16:00:48 +00:00
|
|
|
; CHECK-NEXT: sdiv exact
|
|
|
|
; CHECK-NEXT: sdiv
|
2011-05-05 21:59:18 +00:00
|
|
|
; CHECK-NEXT: icmp
|
|
|
|
define i1 @test53(i32 %a, i32 %b) nounwind {
|
2013-11-16 16:00:48 +00:00
|
|
|
%x = sdiv exact i32 %a, 30
|
|
|
|
%y = sdiv i32 %b, 30
|
2011-05-05 21:59:18 +00:00
|
|
|
%z = icmp eq i32 %x, %y
|
|
|
|
ret i1 %z
|
|
|
|
}
|
2011-06-12 22:48:00 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test54(
|
2011-06-12 22:48:00 +00:00
|
|
|
; CHECK-NEXT: %and = and i8 %a, -64
|
2012-01-05 00:43:34 +00:00
|
|
|
; CHECK-NEXT: icmp eq i8 %and, -128
|
2011-06-12 22:48:00 +00:00
|
|
|
define i1 @test54(i8 %a) nounwind {
|
|
|
|
%ext = zext i8 %a to i32
|
|
|
|
%and = and i32 %ext, 192
|
|
|
|
%ret = icmp eq i32 %and, 128
|
|
|
|
ret i1 %ret
|
|
|
|
}
|
2011-06-13 15:24:24 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test55(
|
2011-06-13 15:24:24 +00:00
|
|
|
; CHECK-NEXT: icmp eq i32 %a, -123
|
|
|
|
define i1 @test55(i32 %a) {
|
|
|
|
%sub = sub i32 0, %a
|
|
|
|
%cmp = icmp eq i32 %sub, 123
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test56(
|
2011-06-13 15:24:24 +00:00
|
|
|
; CHECK-NEXT: icmp eq i32 %a, -113
|
|
|
|
define i1 @test56(i32 %a) {
|
|
|
|
%sub = sub i32 10, %a
|
|
|
|
%cmp = icmp eq i32 %sub, 123
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2011-07-04 20:16:36 +00:00
|
|
|
|
|
|
|
; PR10267 Don't make icmps more expensive when no other inst is subsumed.
|
|
|
|
declare void @foo(i32)
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test57(
|
2011-07-04 20:16:36 +00:00
|
|
|
; CHECK: %and = and i32 %a, -2
|
|
|
|
; CHECK: %cmp = icmp ne i32 %and, 0
|
|
|
|
define i1 @test57(i32 %a) {
|
|
|
|
%and = and i32 %a, -2
|
|
|
|
%cmp = icmp ne i32 %and, 0
|
|
|
|
call void @foo(i32 %and)
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2011-12-01 04:35:26 +00:00
|
|
|
|
|
|
|
; rdar://problem/10482509
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @cmpabs1(
|
2011-12-01 04:35:26 +00:00
|
|
|
; CHECK-NEXT: icmp ne
|
2011-12-01 19:13:26 +00:00
|
|
|
define zeroext i1 @cmpabs1(i64 %val) {
|
2011-12-01 04:35:26 +00:00
|
|
|
%sub = sub nsw i64 0, %val
|
|
|
|
%cmp = icmp slt i64 %val, 0
|
|
|
|
%sub.val = select i1 %cmp, i64 %sub, i64 %val
|
|
|
|
%tobool = icmp ne i64 %sub.val, 0
|
|
|
|
ret i1 %tobool
|
|
|
|
}
|
2011-12-01 19:13:26 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @cmpabs2(
|
2011-12-01 19:13:26 +00:00
|
|
|
; CHECK-NEXT: icmp ne
|
|
|
|
define zeroext i1 @cmpabs2(i64 %val) {
|
|
|
|
%sub = sub nsw i64 0, %val
|
|
|
|
%cmp = icmp slt i64 %val, 0
|
|
|
|
%sub.val = select i1 %cmp, i64 %val, i64 %sub
|
|
|
|
%tobool = icmp ne i64 %sub.val, 0
|
|
|
|
ret i1 %tobool
|
|
|
|
}
|
2012-01-27 22:42:48 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test58(
|
2012-01-27 23:33:07 +00:00
|
|
|
; CHECK-NEXT: call i32 @test58_d(i64 36029346783166592)
|
2012-01-27 22:42:48 +00:00
|
|
|
define void @test58() nounwind {
|
2012-01-27 23:33:07 +00:00
|
|
|
%cast = bitcast <1 x i64> <i64 36029346783166592> to i64
|
|
|
|
%call = call i32 @test58_d( i64 %cast) nounwind
|
2012-01-27 22:42:48 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
declare i32 @test58_d(i64)
|
2012-02-20 15:07:47 +00:00
|
|
|
|
|
|
|
define i1 @test59(i8* %foo) {
|
|
|
|
%bit = bitcast i8* %foo to i32*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32* %bit, i64 2
|
|
|
|
%gep2 = getelementptr inbounds i8, i8* %foo, i64 10
|
2012-02-20 15:07:47 +00:00
|
|
|
%cast1 = bitcast i32* %gep1 to i8*
|
|
|
|
%cmp = icmp ult i8* %cast1, %gep2
|
|
|
|
%use = ptrtoint i8* %cast1 to i64
|
|
|
|
%call = call i32 @test58_d(i64 %use) nounwind
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test59(
|
2012-02-20 15:07:47 +00:00
|
|
|
; CHECK: ret i1 true
|
|
|
|
}
|
|
|
|
|
2013-08-21 19:53:10 +00:00
|
|
|
define i1 @test59_as1(i8 addrspace(1)* %foo) {
|
|
|
|
%bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32 addrspace(1)* %bit, i64 2
|
|
|
|
%gep2 = getelementptr inbounds i8, i8 addrspace(1)* %foo, i64 10
|
2013-08-21 19:53:10 +00:00
|
|
|
%cast1 = bitcast i32 addrspace(1)* %gep1 to i8 addrspace(1)*
|
|
|
|
%cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
|
|
|
|
%use = ptrtoint i8 addrspace(1)* %cast1 to i64
|
|
|
|
%call = call i32 @test58_d(i64 %use) nounwind
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK: @test59_as1
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
; CHECK: %[[GEP:.+]] = getelementptr inbounds i8, i8 addrspace(1)* %foo, i16 8
|
2013-08-21 19:53:10 +00:00
|
|
|
; CHECK: ptrtoint i8 addrspace(1)* %[[GEP]] to i16
|
|
|
|
; CHECK: ret i1 true
|
|
|
|
}
|
|
|
|
|
2012-02-20 15:07:47 +00:00
|
|
|
define i1 @test60(i8* %foo, i64 %i, i64 %j) {
|
|
|
|
%bit = bitcast i8* %foo to i32*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32* %bit, i64 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8* %foo, i64 %j
|
2012-02-20 15:07:47 +00:00
|
|
|
%cast1 = bitcast i32* %gep1 to i8*
|
|
|
|
%cmp = icmp ult i8* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test60(
|
2012-02-20 15:07:47 +00:00
|
|
|
; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2
|
|
|
|
; CHECK-NEXT: icmp slt i64 %gep1.idx, %j
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
2012-02-20 19:00:28 +00:00
|
|
|
|
2013-08-21 19:53:10 +00:00
|
|
|
define i1 @test60_as1(i8 addrspace(1)* %foo, i64 %i, i64 %j) {
|
|
|
|
%bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32 addrspace(1)* %bit, i64 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8 addrspace(1)* %foo, i64 %j
|
2013-08-21 19:53:10 +00:00
|
|
|
%cast1 = bitcast i32 addrspace(1)* %gep1 to i8 addrspace(1)*
|
|
|
|
%cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK: @test60_as1
|
|
|
|
; CHECK: trunc i64 %i to i16
|
|
|
|
; CHECK: trunc i64 %j to i16
|
|
|
|
; CHECK: %gep1.idx = shl nuw i16 %{{.+}}, 2
|
|
|
|
; CHECK-NEXT: icmp sgt i16 %{{.+}}, %gep1.idx
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
|
|
|
|
2014-06-09 19:20:29 +00:00
|
|
|
; Same as test60, but look through an addrspacecast instead of a
|
|
|
|
; bitcast. This uses the same sized addrspace.
|
|
|
|
define i1 @test60_addrspacecast(i8* %foo, i64 %i, i64 %j) {
|
|
|
|
%bit = addrspacecast i8* %foo to i32 addrspace(3)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32 addrspace(3)* %bit, i64 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8* %foo, i64 %j
|
2014-06-09 19:20:29 +00:00
|
|
|
%cast1 = addrspacecast i32 addrspace(3)* %gep1 to i8*
|
|
|
|
%cmp = icmp ult i8* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK-LABEL: @test60_addrspacecast(
|
|
|
|
; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2
|
|
|
|
; CHECK-NEXT: icmp slt i64 %gep1.idx, %j
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test60_addrspacecast_smaller(i8* %foo, i16 %i, i64 %j) {
|
|
|
|
%bit = addrspacecast i8* %foo to i32 addrspace(1)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32 addrspace(1)* %bit, i16 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8* %foo, i64 %j
|
2014-06-09 19:20:29 +00:00
|
|
|
%cast1 = addrspacecast i32 addrspace(1)* %gep1 to i8*
|
|
|
|
%cmp = icmp ult i8* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK-LABEL: @test60_addrspacecast_smaller(
|
|
|
|
; CHECK-NEXT: %gep1.idx = shl nuw i16 %i, 2
|
|
|
|
; CHECK-NEXT: trunc i64 %j to i16
|
|
|
|
; CHECK-NEXT: icmp sgt i16 %1, %gep1.idx
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test60_addrspacecast_larger(i8 addrspace(1)* %foo, i32 %i, i16 %j) {
|
|
|
|
%bit = addrspacecast i8 addrspace(1)* %foo to i32 addrspace(2)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr inbounds i32, i32 addrspace(2)* %bit, i32 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8 addrspace(1)* %foo, i16 %j
|
2014-06-09 19:20:29 +00:00
|
|
|
%cast1 = addrspacecast i32 addrspace(2)* %gep1 to i8 addrspace(1)*
|
|
|
|
%cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
|
|
|
; CHECK-LABEL: @test60_addrspacecast_larger(
|
|
|
|
; CHECK-NEXT: %gep1.idx = shl nuw i32 %i, 2
|
|
|
|
; CHECK-NEXT: trunc i32 %gep1.idx to i16
|
|
|
|
; CHECK-NEXT: icmp slt i16 %1, %j
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
|
|
|
|
2012-02-20 19:00:28 +00:00
|
|
|
define i1 @test61(i8* %foo, i64 %i, i64 %j) {
|
|
|
|
%bit = bitcast i8* %foo to i32*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr i32, i32* %bit, i64 %i
|
|
|
|
%gep2 = getelementptr i8, i8* %foo, i64 %j
|
2012-02-20 19:00:28 +00:00
|
|
|
%cast1 = bitcast i32* %gep1 to i8*
|
|
|
|
%cmp = icmp ult i8* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
|
|
|
; Don't transform non-inbounds GEPs.
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test61(
|
2012-02-20 19:00:28 +00:00
|
|
|
; CHECK: icmp ult i8* %cast1, %gep2
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
2012-02-21 13:31:09 +00:00
|
|
|
|
2013-08-21 19:53:10 +00:00
|
|
|
define i1 @test61_as1(i8 addrspace(1)* %foo, i16 %i, i16 %j) {
|
|
|
|
%bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%gep1 = getelementptr i32, i32 addrspace(1)* %bit, i16 %i
|
|
|
|
%gep2 = getelementptr i8, i8 addrspace(1)* %foo, i16 %j
|
2013-08-21 19:53:10 +00:00
|
|
|
%cast1 = bitcast i32 addrspace(1)* %gep1 to i8 addrspace(1)*
|
|
|
|
%cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
|
|
|
|
ret i1 %cmp
|
|
|
|
; Don't transform non-inbounds GEPs.
|
|
|
|
; CHECK: @test61_as1
|
|
|
|
; CHECK: icmp ult i8 addrspace(1)* %cast1, %gep2
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
|
|
|
|
2012-02-21 13:31:09 +00:00
|
|
|
define i1 @test62(i8* %a) {
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%arrayidx1 = getelementptr inbounds i8, i8* %a, i64 1
|
|
|
|
%arrayidx2 = getelementptr inbounds i8, i8* %a, i64 10
|
2012-02-21 13:31:09 +00:00
|
|
|
%cmp = icmp slt i8* %arrayidx1, %arrayidx2
|
|
|
|
ret i1 %cmp
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test62(
|
2012-02-26 02:09:49 +00:00
|
|
|
; CHECK-NEXT: ret i1 true
|
2012-02-21 13:31:09 +00:00
|
|
|
}
|
2012-06-10 20:35:00 +00:00
|
|
|
|
2013-08-21 19:53:10 +00:00
|
|
|
define i1 @test62_as1(i8 addrspace(1)* %a) {
|
|
|
|
; CHECK-LABEL: @test62_as1(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%arrayidx1 = getelementptr inbounds i8, i8 addrspace(1)* %a, i64 1
|
|
|
|
%arrayidx2 = getelementptr inbounds i8, i8 addrspace(1)* %a, i64 10
|
2013-08-21 19:53:10 +00:00
|
|
|
%cmp = icmp slt i8 addrspace(1)* %arrayidx1, %arrayidx2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2012-06-10 20:35:00 +00:00
|
|
|
define i1 @test63(i8 %a, i32 %b) nounwind {
|
|
|
|
%z = zext i8 %a to i32
|
|
|
|
%t = and i32 %b, 255
|
|
|
|
%c = icmp eq i32 %z, %t
|
|
|
|
ret i1 %c
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test63(
|
2012-06-10 20:35:00 +00:00
|
|
|
; CHECK-NEXT: %1 = trunc i32 %b to i8
|
|
|
|
; CHECK-NEXT: %c = icmp eq i8 %1, %a
|
|
|
|
; CHECK-NEXT: ret i1 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test64(i8 %a, i32 %b) nounwind {
|
|
|
|
%t = and i32 %b, 255
|
|
|
|
%z = zext i8 %a to i32
|
|
|
|
%c = icmp eq i32 %t, %z
|
|
|
|
ret i1 %c
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test64(
|
2012-06-10 20:35:00 +00:00
|
|
|
; CHECK-NEXT: %1 = trunc i32 %b to i8
|
|
|
|
; CHECK-NEXT: %c = icmp eq i8 %1, %a
|
|
|
|
; CHECK-NEXT: ret i1 %c
|
|
|
|
}
|
2012-11-16 18:55:49 +00:00
|
|
|
|
|
|
|
define i1 @test65(i64 %A, i64 %B) {
|
|
|
|
%s1 = add i64 %A, %B
|
|
|
|
%s2 = add i64 %A, %B
|
|
|
|
%cmp = icmp eq i64 %s1, %s2
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test65(
|
2012-11-16 18:55:49 +00:00
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test66(i64 %A, i64 %B) {
|
|
|
|
%s1 = add i64 %A, %B
|
|
|
|
%s2 = add i64 %B, %A
|
|
|
|
%cmp = icmp eq i64 %s1, %s2
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test66(
|
2012-11-16 18:55:49 +00:00
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2012-12-19 19:47:13 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test67(
|
2012-12-19 19:47:13 +00:00
|
|
|
; CHECK: %and = and i32 %x, 96
|
|
|
|
; CHECK: %cmp = icmp ne i32 %and, 0
|
|
|
|
define i1 @test67(i32 %x) nounwind uwtable {
|
|
|
|
%and = and i32 %x, 127
|
|
|
|
%cmp = icmp sgt i32 %and, 31
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test68(
|
2012-12-19 19:47:13 +00:00
|
|
|
; CHECK: %cmp = icmp ugt i32 %and, 30
|
|
|
|
define i1 @test68(i32 %x) nounwind uwtable {
|
|
|
|
%and = and i32 %x, 127
|
|
|
|
%cmp = icmp sgt i32 %and, 30
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2012-12-31 00:34:55 +00:00
|
|
|
|
|
|
|
; PR14708
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test69(
|
2012-12-31 00:34:55 +00:00
|
|
|
; CHECK: %1 = and i32 %c, -33
|
|
|
|
; CHECK: %2 = icmp eq i32 %1, 65
|
2012-12-31 18:26:42 +00:00
|
|
|
; CHECK: ret i1 %2
|
2012-12-31 00:34:55 +00:00
|
|
|
define i1 @test69(i32 %c) nounwind uwtable {
|
|
|
|
%1 = icmp eq i32 %c, 97
|
|
|
|
%2 = icmp eq i32 %c, 65
|
|
|
|
%3 = or i1 %1, %2
|
|
|
|
ret i1 %3
|
|
|
|
}
|
2013-02-15 14:35:47 +00:00
|
|
|
|
2013-05-09 16:32:32 +00:00
|
|
|
; PR15940
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @test70(
|
2013-05-09 16:32:32 +00:00
|
|
|
; CHECK-NEXT: %A = srem i32 5, %X
|
|
|
|
; CHECK-NEXT: %C = icmp ne i32 %A, 2
|
|
|
|
; CHECK-NEXT: ret i1 %C
|
|
|
|
define i1 @test70(i32 %X) {
|
|
|
|
%A = srem i32 5, %X
|
|
|
|
%B = add i32 %A, 2
|
|
|
|
%C = icmp ne i32 %B, 4
|
|
|
|
ret i1 %C
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sext16trunc(
|
2013-02-15 14:35:47 +00:00
|
|
|
; CHECK-NEXT: %1 = trunc i32 %x to i16
|
|
|
|
; CHECK-NEXT: %cmp = icmp slt i16 %1, 36
|
|
|
|
define i1 @icmp_sext16trunc(i32 %x) {
|
|
|
|
%trunc = trunc i32 %x to i16
|
|
|
|
%sext = sext i16 %trunc to i32
|
|
|
|
%cmp = icmp slt i32 %sext, 36
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sext8trunc(
|
2013-02-15 14:35:47 +00:00
|
|
|
; CHECK-NEXT: %1 = trunc i32 %x to i8
|
|
|
|
; CHECK-NEXT: %cmp = icmp slt i8 %1, 36
|
|
|
|
define i1 @icmp_sext8trunc(i32 %x) {
|
|
|
|
%trunc = trunc i32 %x to i8
|
|
|
|
%sext = sext i8 %trunc to i32
|
|
|
|
%cmp = icmp slt i32 %sext, 36
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl16(
|
2013-02-15 14:35:47 +00:00
|
|
|
; CHECK-NEXT: %1 = trunc i32 %x to i16
|
|
|
|
; CHECK-NEXT: %cmp = icmp slt i16 %1, 36
|
|
|
|
define i1 @icmp_shl16(i32 %x) {
|
|
|
|
%shl = shl i32 %x, 16
|
|
|
|
%cmp = icmp slt i32 %shl, 2359296
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl24(
|
2013-02-15 14:35:47 +00:00
|
|
|
; CHECK-NEXT: %1 = trunc i32 %x to i8
|
|
|
|
; CHECK-NEXT: %cmp = icmp slt i8 %1, 36
|
|
|
|
define i1 @icmp_shl24(i32 %x) {
|
|
|
|
%shl = shl i32 %x, 24
|
|
|
|
%cmp = icmp slt i32 %shl, 603979776
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-03-25 09:48:49 +00:00
|
|
|
|
|
|
|
; If the (shl x, C) preserved the sign and this is a sign test,
|
|
|
|
; compare the LHS operand instead
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_nsw_sgt(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp sgt i32 %x, 0
|
|
|
|
define i1 @icmp_shl_nsw_sgt(i32 %x) {
|
|
|
|
%shl = shl nsw i32 %x, 21
|
|
|
|
%cmp = icmp sgt i32 %shl, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_nsw_sge0(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp sgt i32 %x, -1
|
|
|
|
define i1 @icmp_shl_nsw_sge0(i32 %x) {
|
|
|
|
%shl = shl nsw i32 %x, 21
|
|
|
|
%cmp = icmp sge i32 %shl, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_nsw_sge1(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp sgt i32 %x, 0
|
|
|
|
define i1 @icmp_shl_nsw_sge1(i32 %x) {
|
|
|
|
%shl = shl nsw i32 %x, 21
|
|
|
|
%cmp = icmp sge i32 %shl, 1
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; Checks for icmp (eq|ne) (shl x, C), 0
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_nsw_eq(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp eq i32 %x, 0
|
|
|
|
define i1 @icmp_shl_nsw_eq(i32 %x) {
|
|
|
|
%mul = shl nsw i32 %x, 5
|
|
|
|
%cmp = icmp eq i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_eq(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NOT: icmp eq i32 %mul, 0
|
|
|
|
define i1 @icmp_shl_eq(i32 %x) {
|
|
|
|
%mul = shl i32 %x, 5
|
|
|
|
%cmp = icmp eq i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_nsw_ne(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp ne i32 %x, 0
|
|
|
|
define i1 @icmp_shl_nsw_ne(i32 %x) {
|
|
|
|
%mul = shl nsw i32 %x, 7
|
|
|
|
%cmp = icmp ne i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_ne(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NOT: icmp ne i32 %x, 0
|
|
|
|
define i1 @icmp_shl_ne(i32 %x) {
|
|
|
|
%mul = shl i32 %x, 7
|
|
|
|
%cmp = icmp ne i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; If the (mul x, C) preserved the sign and this is sign test,
|
|
|
|
; compare the LHS operand instead
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_nsw(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp sgt i32 %x, 0
|
|
|
|
define i1 @icmp_mul_nsw(i32 %x) {
|
|
|
|
%mul = mul nsw i32 %x, 12
|
|
|
|
%cmp = icmp sgt i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_nsw1(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp slt i32 %x, 0
|
|
|
|
define i1 @icmp_mul_nsw1(i32 %x) {
|
|
|
|
%mul = mul nsw i32 %x, 12
|
|
|
|
%cmp = icmp sle i32 %mul, -1
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_nsw_neg(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp slt i32 %x, 1
|
|
|
|
define i1 @icmp_mul_nsw_neg(i32 %x) {
|
|
|
|
%mul = mul nsw i32 %x, -12
|
|
|
|
%cmp = icmp sge i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_nsw_neg1(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp slt i32 %x, 0
|
|
|
|
define i1 @icmp_mul_nsw_neg1(i32 %x) {
|
|
|
|
%mul = mul nsw i32 %x, -12
|
|
|
|
%cmp = icmp sge i32 %mul, 1
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_nsw_0(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NOT: icmp sgt i32 %x, 0
|
|
|
|
define i1 @icmp_mul_nsw_0(i32 %x) {
|
|
|
|
%mul = mul nsw i32 %x, 0
|
|
|
|
%cmp = icmp sgt i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: %mul = mul i32 %x, -12
|
|
|
|
define i1 @icmp_mul(i32 %x) {
|
|
|
|
%mul = mul i32 %x, -12
|
|
|
|
%cmp = icmp sge i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; Checks for icmp (eq|ne) (mul x, C), 0
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_neq0(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp ne i32 %x, 0
|
|
|
|
define i1 @icmp_mul_neq0(i32 %x) {
|
2013-03-25 11:47:38 +00:00
|
|
|
%mul = mul nsw i32 %x, -12
|
2013-03-25 09:48:49 +00:00
|
|
|
%cmp = icmp ne i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul_eq0(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: icmp eq i32 %x, 0
|
|
|
|
define i1 @icmp_mul_eq0(i32 %x) {
|
2013-03-25 11:47:38 +00:00
|
|
|
%mul = mul nsw i32 %x, 12
|
2013-03-25 09:48:49 +00:00
|
|
|
%cmp = icmp eq i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul0_eq0(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
define i1 @icmp_mul0_eq0(i32 %x) {
|
|
|
|
%mul = mul i32 %x, 0
|
|
|
|
%cmp = icmp eq i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_mul0_ne0(
|
2013-03-25 09:48:49 +00:00
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
define i1 @icmp_mul0_ne0(i32 %x) {
|
|
|
|
%mul = mul i32 %x, 0
|
|
|
|
%cmp = icmp ne i32 %mul, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-04-11 20:05:46 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sub1_sge(
|
2013-04-11 20:05:46 +00:00
|
|
|
; CHECK-NEXT: icmp sgt i32 %x, %y
|
|
|
|
define i1 @icmp_sub1_sge(i32 %x, i32 %y) {
|
|
|
|
%sub = add nsw i32 %x, -1
|
|
|
|
%cmp = icmp sge i32 %sub, %y
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_add1_sgt(
|
2013-04-11 20:05:46 +00:00
|
|
|
; CHECK-NEXT: icmp sge i32 %x, %y
|
|
|
|
define i1 @icmp_add1_sgt(i32 %x, i32 %y) {
|
|
|
|
%add = add nsw i32 %x, 1
|
|
|
|
%cmp = icmp sgt i32 %add, %y
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sub1_slt(
|
2013-04-11 20:05:46 +00:00
|
|
|
; CHECK-NEXT: icmp sle i32 %x, %y
|
|
|
|
define i1 @icmp_sub1_slt(i32 %x, i32 %y) {
|
|
|
|
%sub = add nsw i32 %x, -1
|
|
|
|
%cmp = icmp slt i32 %sub, %y
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_add1_sle(
|
2013-04-11 20:05:46 +00:00
|
|
|
; CHECK-NEXT: icmp slt i32 %x, %y
|
|
|
|
define i1 @icmp_add1_sle(i32 %x, i32 %y) {
|
|
|
|
%add = add nsw i32 %x, 1
|
|
|
|
%cmp = icmp sle i32 %add, %y
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_add20_sge_add57(
|
2013-04-11 20:05:46 +00:00
|
|
|
; CHECK-NEXT: [[ADD:%[a-z0-9]+]] = add nsw i32 %y, 37
|
|
|
|
; CHECK-NEXT: icmp sle i32 [[ADD]], %x
|
|
|
|
define i1 @icmp_add20_sge_add57(i32 %x, i32 %y) {
|
|
|
|
%1 = add nsw i32 %x, 20
|
|
|
|
%2 = add nsw i32 %y, 57
|
|
|
|
%cmp = icmp sge i32 %1, %2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sub57_sge_sub20(
|
2013-04-11 20:05:46 +00:00
|
|
|
; CHECK-NEXT: [[SUB:%[a-z0-9]+]] = add nsw i32 %x, -37
|
|
|
|
; CHECK-NEXT: icmp sge i32 [[SUB]], %y
|
|
|
|
define i1 @icmp_sub57_sge_sub20(i32 %x, i32 %y) {
|
|
|
|
%1 = add nsw i32 %x, -57
|
|
|
|
%2 = add nsw i32 %y, -20
|
|
|
|
%cmp = icmp sge i32 %1, %2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-04-12 17:25:07 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_and_shl_neg_ne_0(
|
2013-04-12 17:25:07 +00:00
|
|
|
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 1, %B
|
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], %A
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_and_shl_neg_ne_0(i32 %A, i32 %B) {
|
|
|
|
%neg = xor i32 %A, -1
|
|
|
|
%shl = shl i32 1, %B
|
|
|
|
%and = and i32 %shl, %neg
|
|
|
|
%cmp = icmp ne i32 %and, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_and_shl_neg_eq_0(
|
2013-04-12 17:25:07 +00:00
|
|
|
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 1, %B
|
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], %A
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_and_shl_neg_eq_0(i32 %A, i32 %B) {
|
|
|
|
%neg = xor i32 %A, -1
|
|
|
|
%shl = shl i32 1, %B
|
|
|
|
%and = and i32 %shl, %neg
|
|
|
|
%cmp = icmp eq i32 %and, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-04-14 21:15:43 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_add_and_shr_ne_0(
|
2013-04-14 21:15:43 +00:00
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, 240
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 224
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_add_and_shr_ne_0(i32 %X) {
|
|
|
|
%shr = lshr i32 %X, 4
|
|
|
|
%and = and i32 %shr, 15
|
|
|
|
%add = add i32 %and, -14
|
|
|
|
%tobool = icmp ne i32 %add, 0
|
|
|
|
ret i1 %tobool
|
|
|
|
}
|
2013-06-06 19:15:23 +00:00
|
|
|
|
|
|
|
; PR16244
|
2013-07-14 01:50:49 +00:00
|
|
|
; CHECK-LABEL: define i1 @test71(
|
2013-06-06 19:15:23 +00:00
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
define i1 @test71(i8* %x) {
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%a = getelementptr i8, i8* %x, i64 8
|
|
|
|
%b = getelementptr inbounds i8, i8* %x, i64 8
|
2013-06-06 19:15:23 +00:00
|
|
|
%c = icmp ugt i8* %a, %b
|
|
|
|
ret i1 %c
|
|
|
|
}
|
2013-06-28 23:42:03 +00:00
|
|
|
|
2013-08-21 19:53:10 +00:00
|
|
|
define i1 @test71_as1(i8 addrspace(1)* %x) {
|
|
|
|
; CHECK-LABEL: @test71_as1(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%a = getelementptr i8, i8 addrspace(1)* %x, i64 8
|
|
|
|
%b = getelementptr inbounds i8, i8 addrspace(1)* %x, i64 8
|
2013-08-21 19:53:10 +00:00
|
|
|
%c = icmp ugt i8 addrspace(1)* %a, %b
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_ult_32(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %V, 5
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_ult_32(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp ult i32 %shl, 32
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_eq_32(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 %V, 5
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_eq_32(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp eq i32 %shl, 32
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_ult_30(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %V, 5
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_ult_30(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp ult i32 %shl, 30
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_ugt_30(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %V, 4
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_ugt_30(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp ugt i32 %shl, 30
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_ule_30(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %V, 5
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_ule_30(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp ule i32 %shl, 30
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_uge_30(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %V, 4
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_uge_30(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp uge i32 %shl, 30
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_uge_2147483648(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 %V, 31
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_uge_2147483648(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp uge i32 %shl, 2147483648
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_shl_1_V_ult_2147483648(
|
2013-06-28 23:42:03 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 %V, 31
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_shl_1_V_ult_2147483648(i32 %V) {
|
|
|
|
%shl = shl i32 1, %V
|
|
|
|
%cmp = icmp ult i32 %shl, 2147483648
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
InstCombine: (icmp eq B, 0) | (icmp ult A, B) -> (icmp ule A, B-1)
This transform allows us to turn IR that looks like:
%1 = icmp eq i64 %b, 0
%2 = icmp ult i64 %a, %b
%3 = or i1 %1, %2
ret i1 %3
into:
%0 = add i64 %b, -1
%1 = icmp uge i64 %0, %a
ret i1 %1
which means we go from lowering:
cmpq %rsi, %rdi
setb %cl
testq %rsi, %rsi
sete %al
orb %cl, %al
ret
to lowering:
decq %rsi
cmpq %rdi, %rsi
setae %al
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185677 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-05 00:31:17 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @or_icmp_eq_B_0_icmp_ult_A_B(
|
2013-07-06 00:54:07 +00:00
|
|
|
; CHECK-NEXT: [[SUB:%[a-z0-9]+]] = add i64 %b, -1
|
InstCombine: (icmp eq B, 0) | (icmp ult A, B) -> (icmp ule A, B-1)
This transform allows us to turn IR that looks like:
%1 = icmp eq i64 %b, 0
%2 = icmp ult i64 %a, %b
%3 = or i1 %1, %2
ret i1 %3
into:
%0 = add i64 %b, -1
%1 = icmp uge i64 %0, %a
ret i1 %1
which means we go from lowering:
cmpq %rsi, %rdi
setb %cl
testq %rsi, %rsi
sete %al
orb %cl, %al
ret
to lowering:
decq %rsi
cmpq %rdi, %rsi
setae %al
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185677 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-05 00:31:17 +00:00
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp uge i64 [[SUB]], %a
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @or_icmp_eq_B_0_icmp_ult_A_B(i64 %a, i64 %b) {
|
|
|
|
%1 = icmp eq i64 %b, 0
|
|
|
|
%2 = icmp ult i64 %a, %b
|
|
|
|
%3 = or i1 %1, %2
|
|
|
|
ret i1 %3
|
|
|
|
}
|
2013-07-08 11:53:08 +00:00
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_add_ult_2(
|
2013-07-08 11:53:08 +00:00
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, -2
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 14
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_add_ult_2(i32 %X) {
|
|
|
|
%add = add i32 %X, -14
|
|
|
|
%cmp = icmp ult i32 %add, 2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-07-09 07:50:59 +00:00
|
|
|
|
|
|
|
; CHECK: @icmp_add_X_-14_ult_2
|
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, -2
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 14
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_add_X_-14_ult_2(i32 %X) {
|
|
|
|
%add = add i32 %X, -14
|
|
|
|
%cmp = icmp ult i32 %add, 2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sub_3_X_ult_2(
|
2013-07-09 07:58:32 +00:00
|
|
|
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 %X, 1
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[OR]], 3
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_sub_3_X_ult_2(i32 %X) {
|
|
|
|
%add = sub i32 3, %X
|
|
|
|
%cmp = icmp ult i32 %add, 2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: @icmp_add_X_-14_uge_2
|
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, -2
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 14
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_add_X_-14_uge_2(i32 %X) {
|
|
|
|
%add = add i32 %X, -14
|
|
|
|
%cmp = icmp uge i32 %add, 2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2013-07-14 01:42:54 +00:00
|
|
|
; CHECK-LABEL: @icmp_sub_3_X_uge_2(
|
2013-07-09 07:58:32 +00:00
|
|
|
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 %X, 1
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[OR]], 3
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_sub_3_X_uge_2(i32 %X) {
|
|
|
|
%add = sub i32 3, %X
|
|
|
|
%cmp = icmp uge i32 %add, 2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: @icmp_and_X_-16_eq-16
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %X, -17
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_and_X_-16_eq-16(i32 %X) {
|
|
|
|
%and = and i32 %X, -16
|
|
|
|
%cmp = icmp eq i32 %and, -16
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: @icmp_and_X_-16_ne-16
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, -16
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_and_X_-16_ne-16(i32 %X) {
|
|
|
|
%and = and i32 %X, -16
|
|
|
|
%cmp = icmp ne i32 %and, -16
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-07-09 09:20:58 +00:00
|
|
|
|
|
|
|
; CHECK: @icmp_sub_-1_X_ult_4
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %X, -5
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_sub_-1_X_ult_4(i32 %X) {
|
|
|
|
%sub = sub i32 -1, %X
|
|
|
|
%cmp = icmp ult i32 %sub, 4
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: @icmp_sub_-1_X_uge_4
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, -4
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_sub_-1_X_uge_4(i32 %X) {
|
|
|
|
%sub = sub i32 -1, %X
|
|
|
|
%cmp = icmp uge i32 %sub, 4
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2013-09-09 20:56:48 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_swap_operands_for_cse
|
|
|
|
; CHECK: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, %Y
|
|
|
|
; CHECK-NEXT: br i1 [[CMP]], label %true, label %false
|
|
|
|
; CHECK: ret i1
|
|
|
|
define i1 @icmp_swap_operands_for_cse(i32 %X, i32 %Y) {
|
|
|
|
entry:
|
|
|
|
%sub = sub i32 %X, %Y
|
|
|
|
%cmp = icmp ugt i32 %Y, %X
|
|
|
|
br i1 %cmp, label %true, label %false
|
|
|
|
true:
|
|
|
|
%restrue = trunc i32 %sub to i1
|
|
|
|
br label %end
|
|
|
|
false:
|
|
|
|
%shift = lshr i32 %sub, 4
|
|
|
|
%resfalse = trunc i32 %shift to i1
|
|
|
|
br label %end
|
|
|
|
end:
|
|
|
|
%res = phi i1 [%restrue, %true], [%resfalse, %false]
|
|
|
|
ret i1 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_swap_operands_for_cse2
|
|
|
|
; CHECK: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, %Y
|
|
|
|
; CHECK-NEXT: br i1 [[CMP]], label %true, label %false
|
|
|
|
; CHECK: ret i1
|
|
|
|
define i1 @icmp_swap_operands_for_cse2(i32 %X, i32 %Y) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %Y, %X
|
|
|
|
br i1 %cmp, label %true, label %false
|
|
|
|
true:
|
|
|
|
%sub = sub i32 %X, %Y
|
|
|
|
%sub1 = sub i32 %X, %Y
|
|
|
|
%add = add i32 %sub, %sub1
|
|
|
|
%restrue = trunc i32 %add to i1
|
|
|
|
br label %end
|
|
|
|
false:
|
|
|
|
%sub2 = sub i32 %Y, %X
|
|
|
|
%resfalse = trunc i32 %sub2 to i1
|
|
|
|
br label %end
|
|
|
|
end:
|
|
|
|
%res = phi i1 [%restrue, %true], [%resfalse, %false]
|
|
|
|
ret i1 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_do_not_swap_operands_for_cse
|
|
|
|
; CHECK: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %Y, %X
|
|
|
|
; CHECK-NEXT: br i1 [[CMP]], label %true, label %false
|
|
|
|
; CHECK: ret i1
|
|
|
|
define i1 @icmp_do_not_swap_operands_for_cse(i32 %X, i32 %Y) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %Y, %X
|
|
|
|
br i1 %cmp, label %true, label %false
|
|
|
|
true:
|
|
|
|
%sub = sub i32 %X, %Y
|
|
|
|
%restrue = trunc i32 %sub to i1
|
|
|
|
br label %end
|
|
|
|
false:
|
|
|
|
%sub2 = sub i32 %Y, %X
|
|
|
|
%resfalse = trunc i32 %sub2 to i1
|
|
|
|
br label %end
|
|
|
|
end:
|
|
|
|
%res = phi i1 [%restrue, %true], [%resfalse, %false]
|
|
|
|
ret i1 %res
|
|
|
|
}
|
2013-11-16 16:00:48 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_lshr_lshr_eq
|
|
|
|
; CHECK: %z.unshifted = xor i32 %a, %b
|
|
|
|
; CHECK: %z = icmp ult i32 %z.unshifted, 1073741824
|
|
|
|
define i1 @icmp_lshr_lshr_eq(i32 %a, i32 %b) nounwind {
|
|
|
|
%x = lshr i32 %a, 30
|
|
|
|
%y = lshr i32 %b, 30
|
|
|
|
%z = icmp eq i32 %x, %y
|
|
|
|
ret i1 %z
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_ashr_ashr_ne
|
|
|
|
; CHECK: %z.unshifted = xor i32 %a, %b
|
|
|
|
; CHECK: %z = icmp ugt i32 %z.unshifted, 255
|
|
|
|
define i1 @icmp_ashr_ashr_ne(i32 %a, i32 %b) nounwind {
|
|
|
|
%x = ashr i32 %a, 8
|
|
|
|
%y = ashr i32 %b, 8
|
|
|
|
%z = icmp ne i32 %x, %y
|
|
|
|
ret i1 %z
|
|
|
|
}
|
2014-05-15 00:02:20 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_neg_cst_slt
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp sgt i32 %a, 10
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_neg_cst_slt(i32 %a) {
|
|
|
|
%1 = sub nsw i32 0, %a
|
|
|
|
%2 = icmp slt i32 %1, -10
|
|
|
|
ret i1 %2
|
|
|
|
}
|
InstCombine: Properly optimize or'ing bittests together
CFE, with -03, would turn:
bool f(unsigned x) {
bool a = x & 1;
bool b = x & 2;
return a | b;
}
into:
%1 = lshr i32 %x, 1
%2 = or i32 %1, %x
%3 = and i32 %2, 1
%4 = icmp ne i32 %3, 0
This sort of thing exposes a nasty pathology in GCC, ICC and LLVM.
Instead, we would rather want:
%1 = and i32 %x, 3
%2 = icmp ne i32 %1, 0
Things get a bit more interesting in the following case:
%1 = lshr i32 %x, %y
%2 = or i32 %1, %x
%3 = and i32 %2, 1
%4 = icmp ne i32 %3, 0
Replacing it with the following sequence is better:
%1 = shl nuw i32 1, %y
%2 = or i32 %1, 1
%3 = and i32 %2, %x
%4 = icmp ne i32 %3, 0
This sequence is preferable because %1 doesn't involve %x and could
potentially be hoisted out of loops if it is invariant; only perform
this transform in the non-constant case if we know we won't increase
register pressure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216343 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-24 09:10:57 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_and_or_lshr
|
|
|
|
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl nuw i32 1, %y
|
|
|
|
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 [[SHL]], 1
|
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[OR]], %x
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_and_or_lshr(i32 %x, i32 %y) {
|
|
|
|
%shf = lshr i32 %x, %y
|
|
|
|
%or = or i32 %shf, %x
|
|
|
|
%and = and i32 %or, 1
|
|
|
|
%ret = icmp ne i32 %and, 0
|
|
|
|
ret i1 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_and_or_lshr_cst
|
|
|
|
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %x, 3
|
|
|
|
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
define i1 @icmp_and_or_lshr_cst(i32 %x) {
|
|
|
|
%shf = lshr i32 %x, 1
|
|
|
|
%or = or i32 %shf, %x
|
|
|
|
%and = and i32 %or, 1
|
|
|
|
%ret = icmp ne i32 %and, 0
|
|
|
|
ret i1 %ret
|
|
|
|
}
|
2014-10-19 08:23:08 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_zero_ap2_non_zero_2
|
|
|
|
; CHECK-NEXT: %cmp = icmp ugt i32 %a, 29
|
|
|
|
; CHECK-NEXT: ret i1 %cmp
|
|
|
|
define i1 @shl_ap1_zero_ap2_non_zero_2(i32 %a) {
|
|
|
|
%shl = shl i32 4, %a
|
|
|
|
%cmp = icmp eq i32 %shl, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_zero_ap2_non_zero_4
|
|
|
|
; CHECK-NEXT: %cmp = icmp ugt i32 %a, 30
|
|
|
|
; CHECK-NEXT: ret i1 %cmp
|
|
|
|
define i1 @shl_ap1_zero_ap2_non_zero_4(i32 %a) {
|
|
|
|
%shl = shl i32 -2, %a
|
|
|
|
%cmp = icmp eq i32 %shl, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_non_zero_ap2_non_zero_both_positive
|
|
|
|
; CHECK-NEXT: %cmp = icmp eq i32 %a, 0
|
|
|
|
; CHECK-NEXT: ret i1 %cmp
|
|
|
|
define i1 @shl_ap1_non_zero_ap2_non_zero_both_positive(i32 %a) {
|
|
|
|
%shl = shl i32 50, %a
|
|
|
|
%cmp = icmp eq i32 %shl, 50
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_non_zero_ap2_non_zero_both_negative
|
|
|
|
; CHECK-NEXT: %cmp = icmp eq i32 %a, 0
|
|
|
|
; CHECK-NEXT: ret i1 %cmp
|
|
|
|
define i1 @shl_ap1_non_zero_ap2_non_zero_both_negative(i32 %a) {
|
|
|
|
%shl = shl i32 -50, %a
|
|
|
|
%cmp = icmp eq i32 %shl, -50
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_non_zero_ap2_non_zero_ap1_1
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
define i1 @shl_ap1_non_zero_ap2_non_zero_ap1_1(i32 %a) {
|
|
|
|
%shl = shl i32 50, %a
|
|
|
|
%cmp = icmp eq i32 %shl, 25
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_non_zero_ap2_non_zero_ap1_2
|
|
|
|
; CHECK-NEXT: %cmp = icmp eq i32 %a, 1
|
|
|
|
; CHECK-NEXT: ret i1 %cmp
|
|
|
|
define i1 @shl_ap1_non_zero_ap2_non_zero_ap1_2(i32 %a) {
|
|
|
|
%shl = shl i32 25, %a
|
|
|
|
%cmp = icmp eq i32 %shl, 50
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @shl_ap1_non_zero_ap2_non_zero_ap1_3
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
define i1 @shl_ap1_non_zero_ap2_non_zero_ap1_3(i32 %a) {
|
|
|
|
%shl = shl i32 26, %a
|
|
|
|
%cmp = icmp eq i32 %shl, 50
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2014-11-01 09:09:51 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_sgt_zero_add_nsw
|
|
|
|
; CHECK-NEXT: icmp sgt i32 %a, -1
|
|
|
|
define i1 @icmp_sgt_zero_add_nsw(i32 %a) {
|
|
|
|
%add = add nsw i32 %a, 1
|
|
|
|
%cmp = icmp sgt i32 %add, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_sge_zero_add_nsw
|
|
|
|
; CHECK-NEXT: icmp sgt i32 %a, -2
|
|
|
|
define i1 @icmp_sge_zero_add_nsw(i32 %a) {
|
|
|
|
%add = add nsw i32 %a, 1
|
|
|
|
%cmp = icmp sge i32 %add, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_slt_zero_add_nsw
|
|
|
|
; CHECK-NEXT: icmp slt i32 %a, -1
|
|
|
|
define i1 @icmp_slt_zero_add_nsw(i32 %a) {
|
|
|
|
%add = add nsw i32 %a, 1
|
|
|
|
%cmp = icmp slt i32 %add, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_sle_zero_add_nsw
|
|
|
|
; CHECK-NEXT: icmp slt i32 %a, 0
|
|
|
|
define i1 @icmp_sle_zero_add_nsw(i32 %a) {
|
|
|
|
%add = add nsw i32 %a, 1
|
|
|
|
%cmp = icmp sle i32 %add, 0
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2014-11-06 23:23:30 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @icmp_cmpxchg_strong
|
|
|
|
; CHECK-NEXT: %[[xchg:.*]] = cmpxchg i32* %sc, i32 %old_val, i32 %new_val seq_cst seq_cst
|
|
|
|
; CHECK-NEXT: %[[icmp:.*]] = extractvalue { i32, i1 } %[[xchg]], 1
|
|
|
|
; CHECK-NEXT: ret i1 %[[icmp]]
|
|
|
|
define zeroext i1 @icmp_cmpxchg_strong(i32* %sc, i32 %old_val, i32 %new_val) {
|
|
|
|
%xchg = cmpxchg i32* %sc, i32 %old_val, i32 %new_val seq_cst seq_cst
|
|
|
|
%xtrc = extractvalue { i32, i1 } %xchg, 0
|
|
|
|
%icmp = icmp eq i32 %xtrc, %old_val
|
|
|
|
ret i1 %icmp
|
|
|
|
}
|
2014-12-31 04:21:41 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @f1
|
|
|
|
; CHECK-NEXT: %[[cmp:.*]] = icmp sge i64 %a, %b
|
|
|
|
; CHECK-NEXT: ret i1 %[[cmp]]
|
|
|
|
define i1 @f1(i64 %a, i64 %b) {
|
|
|
|
%t = sub nsw i64 %a, %b
|
|
|
|
%v = icmp sge i64 %t, 0
|
|
|
|
ret i1 %v
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @f2
|
|
|
|
; CHECK-NEXT: %[[cmp:.*]] = icmp sgt i64 %a, %b
|
|
|
|
; CHECK-NEXT: ret i1 %[[cmp]]
|
|
|
|
define i1 @f2(i64 %a, i64 %b) {
|
|
|
|
%t = sub nsw i64 %a, %b
|
|
|
|
%v = icmp sgt i64 %t, 0
|
|
|
|
ret i1 %v
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @f3
|
|
|
|
; CHECK-NEXT: %[[cmp:.*]] = icmp slt i64 %a, %b
|
|
|
|
; CHECK-NEXT: ret i1 %[[cmp]]
|
|
|
|
define i1 @f3(i64 %a, i64 %b) {
|
|
|
|
%t = sub nsw i64 %a, %b
|
|
|
|
%v = icmp slt i64 %t, 0
|
|
|
|
ret i1 %v
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @f4
|
|
|
|
; CHECK-NEXT: %[[cmp:.*]] = icmp sle i64 %a, %b
|
|
|
|
; CHECK-NEXT: ret i1 %[[cmp]]
|
|
|
|
define i1 @f4(i64 %a, i64 %b) {
|
|
|
|
%t = sub nsw i64 %a, %b
|
|
|
|
%v = icmp sle i64 %t, 0
|
|
|
|
ret i1 %v
|
|
|
|
}
|
2015-01-14 19:26:56 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @f5
|
|
|
|
; CHECK: %[[cmp:.*]] = icmp slt i32 %[[sub:.*]], 0
|
|
|
|
; CHECK: %[[neg:.*]] = sub nsw i32 0, %[[sub]]
|
|
|
|
; CHECK: %[[sel:.*]] = select i1 %[[cmp]], i32 %[[neg]], i32 %[[sub]]
|
|
|
|
; CHECK: ret i32 %[[sel]]
|
|
|
|
define i32 @f5(i8 %a, i8 %b) {
|
|
|
|
%conv = zext i8 %a to i32
|
|
|
|
%conv3 = zext i8 %b to i32
|
|
|
|
%sub = sub nsw i32 %conv, %conv3
|
|
|
|
%cmp4 = icmp slt i32 %sub, 0
|
|
|
|
%sub7 = sub nsw i32 0, %sub
|
|
|
|
%sub7.sub = select i1 %cmp4, i32 %sub7, i32 %sub
|
|
|
|
ret i32 %sub7.sub
|
|
|
|
}
|
2015-03-26 17:12:06 +00:00
|
|
|
|
|
|
|
; CHECK-LABEL: @f6
|
|
|
|
; CHECK: %cmp.unshifted = xor i32 %a, %b
|
|
|
|
; CHECK-NEXT: %cmp.mask = and i32 %cmp.unshifted, 255
|
|
|
|
; CHECK-NEXT: %cmp = icmp eq i32 %cmp.mask, 0
|
|
|
|
; CHECK-NEXT: %s = select i1 %cmp, i32 10000, i32 0
|
|
|
|
; CHECK-NEXT: ret i32 %s
|
|
|
|
define i32 @f6(i32 %a, i32 %b) {
|
|
|
|
%sext = shl i32 %a, 24
|
|
|
|
%conv = ashr i32 %sext, 24
|
|
|
|
%sext6 = shl i32 %b, 24
|
|
|
|
%conv4 = ashr i32 %sext6, 24
|
|
|
|
%cmp = icmp eq i32 %conv, %conv4
|
|
|
|
%s = select i1 %cmp, i32 10000, i32 0
|
|
|
|
ret i32 %s
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @f7
|
|
|
|
; CHECK: %cmp.unshifted = xor i32 %a, %b
|
|
|
|
; CHECK-NEXT: %cmp.mask = and i32 %cmp.unshifted, 511
|
|
|
|
; CHECK-NEXT: %cmp = icmp ne i32 %cmp.mask, 0
|
|
|
|
; CHECK-NEXT: %s = select i1 %cmp, i32 10000, i32 0
|
|
|
|
; CHECK-NEXT: ret i32 %s
|
|
|
|
define i32 @f7(i32 %a, i32 %b) {
|
|
|
|
%sext = shl i32 %a, 23
|
|
|
|
%sext6 = shl i32 %b, 23
|
|
|
|
%cmp = icmp ne i32 %sext, %sext6
|
|
|
|
%s = select i1 %cmp, i32 10000, i32 0
|
|
|
|
ret i32 %s
|
|
|
|
}
|