2012-12-30 09:28:40 +08:00
|
|
|
; RUN: opt -analyze -scalar-evolution -S < %s | FileCheck %s
|
2011-01-19 23:56:12 +08:00
|
|
|
|
2011-01-20 00:59:46 +08:00
|
|
|
define i16 @test1(i8 %x) {
|
2011-01-19 23:56:12 +08:00
|
|
|
%A = zext i8 %x to i12
|
|
|
|
%B = sext i12 %A to i16
|
|
|
|
; CHECK: zext i8 %x to i16
|
|
|
|
ret i16 %B
|
|
|
|
}
|
2011-01-20 00:59:46 +08:00
|
|
|
|
|
|
|
define i8 @test2(i8 %x) {
|
|
|
|
%A = zext i8 %x to i16
|
|
|
|
%B = add i16 %A, 1025
|
|
|
|
%C = trunc i16 %B to i8
|
|
|
|
; CHECK: (1 + %x)
|
|
|
|
ret i8 %C
|
|
|
|
}
|
2011-01-20 02:56:00 +08:00
|
|
|
|
|
|
|
define i8 @test3(i8 %x) {
|
|
|
|
%A = zext i8 %x to i16
|
|
|
|
%B = mul i16 %A, 1027
|
|
|
|
%C = trunc i16 %B to i8
|
|
|
|
; CHECK: (3 * %x)
|
|
|
|
ret i8 %C
|
|
|
|
}
|
2011-01-23 14:20:19 +08:00
|
|
|
|
2011-01-24 04:06:05 +08:00
|
|
|
define void @test4(i32 %x, i32 %y) {
|
2011-01-23 14:20:19 +08:00
|
|
|
entry:
|
2011-01-24 04:06:05 +08:00
|
|
|
%Y = and i32 %y, 3
|
|
|
|
br label %loop
|
2011-01-23 14:20:19 +08:00
|
|
|
loop:
|
|
|
|
%A = phi i32 [0, %entry], [%I, %loop]
|
2011-01-24 04:06:05 +08:00
|
|
|
%rand1 = icmp sgt i32 %A, %Y
|
|
|
|
%Z1 = select i1 %rand1, i32 %A, i32 %Y
|
|
|
|
%rand2 = icmp ugt i32 %A, %Z1
|
|
|
|
%Z2 = select i1 %rand2, i32 %A, i32 %Z1
|
|
|
|
; CHECK: %Z2 =
|
2015-03-10 05:43:39 +08:00
|
|
|
; CHECK-NEXT: --> ([[EXPR:.*]]){{ U: [^ ]+ S: [^ ]+}}{{ +}}Exits: 20
|
2011-01-24 04:06:05 +08:00
|
|
|
%B = trunc i32 %Z2 to i16
|
2011-01-23 14:20:19 +08:00
|
|
|
%C = sext i16 %B to i30
|
|
|
|
; CHECK: %C =
|
2011-01-24 04:06:05 +08:00
|
|
|
; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30)
|
2011-01-23 14:20:19 +08:00
|
|
|
%D = sext i16 %B to i32
|
|
|
|
; CHECK: %D =
|
2011-01-24 04:06:05 +08:00
|
|
|
; CHECK-NEXT: ([[EXPR]])
|
2011-01-23 14:20:19 +08:00
|
|
|
%E = sext i16 %B to i34
|
|
|
|
; CHECK: %E =
|
2011-01-24 04:06:05 +08:00
|
|
|
; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
|
2011-01-23 14:20:19 +08:00
|
|
|
%F = zext i16 %B to i30
|
|
|
|
; CHECK: %F =
|
2011-01-24 04:06:05 +08:00
|
|
|
; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30
|
2011-01-23 14:20:19 +08:00
|
|
|
%G = zext i16 %B to i32
|
|
|
|
; CHECK: %G =
|
2011-01-24 04:06:05 +08:00
|
|
|
; CHECK-NEXT: ([[EXPR]])
|
2011-01-23 14:20:19 +08:00
|
|
|
%H = zext i16 %B to i34
|
|
|
|
; CHECK: %H =
|
2011-01-24 04:06:05 +08:00
|
|
|
; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
|
2011-01-23 14:20:19 +08:00
|
|
|
%I = add i32 %A, 1
|
2011-01-24 04:06:05 +08:00
|
|
|
%0 = icmp ne i32 %A, 20
|
|
|
|
br i1 %0, label %loop, label %exit
|
2011-01-23 14:20:19 +08:00
|
|
|
exit:
|
|
|
|
ret void
|
2011-01-24 04:06:05 +08:00
|
|
|
}
|
2014-01-27 18:04:03 +08:00
|
|
|
|
|
|
|
define void @test5(i32 %i) {
|
|
|
|
; CHECK-LABEL: @test5
|
|
|
|
%A = and i32 %i, 1
|
|
|
|
; CHECK: --> (zext i1 (trunc i32 %i to i1) to i32)
|
|
|
|
%B = and i32 %i, 2
|
|
|
|
; CHECK: --> (2 * (zext i1 (trunc i32 (%i /u 2) to i1) to i32))
|
|
|
|
%C = and i32 %i, 63
|
|
|
|
; CHECK: --> (zext i6 (trunc i32 %i to i6) to i32)
|
|
|
|
%D = and i32 %i, 126
|
|
|
|
; CHECK: --> (2 * (zext i6 (trunc i32 (%i /u 2) to i6) to i32))
|
|
|
|
%E = and i32 %i, 64
|
|
|
|
; CHECK: --> (64 * (zext i1 (trunc i32 (%i /u 64) to i1) to i32))
|
|
|
|
%F = and i32 %i, -2147483648
|
|
|
|
; CHECK: --> (-2147483648 * (%i /u -2147483648))
|
|
|
|
ret void
|
|
|
|
}
|
2014-01-27 18:47:44 +08:00
|
|
|
|
|
|
|
define void @test6(i8 %x) {
|
|
|
|
; CHECK-LABEL: @test6
|
|
|
|
%A = zext i8 %x to i16
|
|
|
|
%B = shl nuw i16 %A, 8
|
|
|
|
%C = and i16 %B, -2048
|
|
|
|
; CHECK: --> (2048 * ((zext i8 %x to i16) /u 8))
|
|
|
|
ret void
|
|
|
|
}
|
2015-03-20 10:25:00 +08:00
|
|
|
|
|
|
|
; PR22960
|
|
|
|
define void @test7(i32 %A) {
|
|
|
|
; CHECK-LABEL: @test7
|
|
|
|
%B = sext i32 %A to i64
|
|
|
|
%C = zext i32 %A to i64
|
|
|
|
%D = sub i64 %B, %C
|
|
|
|
%E = trunc i64 %D to i16
|
|
|
|
; CHECK: %E
|
|
|
|
; CHECK-NEXT: --> 0
|
|
|
|
ret void
|
|
|
|
}
|
2018-06-12 02:44:58 +08:00
|
|
|
|
|
|
|
define i64 @test8(i64 %a) {
|
|
|
|
; CHECK-LABEL: @test8
|
|
|
|
%t0 = udiv i64 %a, 56
|
|
|
|
%t1 = udiv i64 %t0, 56
|
|
|
|
; CHECK: %t1
|
|
|
|
; CHECK-NEXT: --> (%a /u 3136)
|
|
|
|
ret i64 %t1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test9(i64 %a) {
|
|
|
|
; CHECK-LABEL: @test9
|
|
|
|
%t0 = udiv i64 %a, 100000000000000
|
|
|
|
%t1 = udiv i64 %t0, 100000000000000
|
|
|
|
; CHECK: %t1
|
|
|
|
; CHECK-NEXT: --> 0
|
|
|
|
ret i64 %t1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test10(i64 %a, i64 %b) {
|
2018-06-12 03:56:12 +08:00
|
|
|
; CHECK-LABEL: @test10
|
2018-06-12 02:44:58 +08:00
|
|
|
%t0 = udiv i64 %a, 100000000000000
|
|
|
|
%t1 = udiv i64 %t0, 100000000000000
|
|
|
|
%t2 = mul i64 %b, %t1
|
|
|
|
; CHECK: %t2
|
|
|
|
; CHECK-NEXT: --> 0
|
|
|
|
ret i64 %t2
|
|
|
|
}
|