Home | History | Annotate | Download | only in ScalarEvolution
      1 ; RUN: opt -analyze -scalar-evolution %s -S | FileCheck %s
      2 
      3 define i16 @test1(i8 %x) {
      4   %A = zext i8 %x to i12
      5   %B = sext i12 %A to i16
      6 ; CHECK: zext i8 %x to i16
      7   ret i16 %B
      8 }
      9 
     10 define i8 @test2(i8 %x) {
     11   %A = zext i8 %x to i16
     12   %B = add i16 %A, 1025
     13   %C = trunc i16 %B to i8
     14 ; CHECK: (1 + %x)
     15   ret i8 %C
     16 }
     17 
     18 define i8 @test3(i8 %x) {
     19   %A = zext i8 %x to i16
     20   %B = mul i16 %A, 1027
     21   %C = trunc i16 %B to i8
     22 ; CHECK: (3 * %x)
     23   ret i8 %C
     24 }
     25 
     26 define void @test4(i32 %x, i32 %y) {
     27 entry:
     28   %Y = and i32 %y, 3
     29   br label %loop
     30 loop:
     31   %A = phi i32 [0, %entry], [%I, %loop]
     32   %rand1 = icmp sgt i32 %A, %Y
     33   %Z1 = select i1 %rand1, i32 %A, i32 %Y
     34   %rand2 = icmp ugt i32 %A, %Z1
     35   %Z2 = select i1 %rand2, i32 %A, i32 %Z1
     36 ; CHECK: %Z2 =
     37 ; CHECK-NEXT: -->  ([[EXPR:.*]]){{ +}}Exits: 20
     38   %B = trunc i32 %Z2 to i16
     39   %C = sext i16 %B to i30
     40 ; CHECK: %C =
     41 ; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30)
     42   %D = sext i16 %B to i32
     43 ; CHECK: %D =
     44 ; CHECK-NEXT: ([[EXPR]])
     45   %E = sext i16 %B to i34
     46 ; CHECK: %E =
     47 ; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
     48   %F = zext i16 %B to i30
     49 ; CHECK: %F =
     50 ; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30
     51   %G = zext i16 %B to i32
     52 ; CHECK: %G =
     53 ; CHECK-NEXT: ([[EXPR]])
     54   %H = zext i16 %B to i34
     55 ; CHECK: %H =
     56 ; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
     57   %I = add i32 %A, 1
     58   %0 = icmp ne i32 %A, 20
     59   br i1 %0, label %loop, label %exit
     60 exit:
     61   ret void
     62 }
     63