Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt < %s -instcombine -S | FileCheck %s
      2 
      3 target datalayout = "e-p: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"
      4 
      5 define i32 @mul(i32 %x, i32 %y) {
      6   %A = trunc i32 %x to i8
      7   %B = trunc i32 %y to i8
      8   %C = mul i8 %A, %B
      9   %D = zext i8 %C to i32
     10   ret i32 %D
     11 ; CHECK: %C = mul i32 %x, %y
     12 ; CHECK: %D = and i32 %C, 255
     13 ; CHECK: ret i32 %D
     14 }
     15 
     16 define i32 @select1(i1 %cond, i32 %x, i32 %y, i32 %z) {
     17   %A = trunc i32 %x to i8
     18   %B = trunc i32 %y to i8
     19   %C = trunc i32 %z to i8
     20   %D = add i8 %A, %B
     21   %E = select i1 %cond, i8 %C, i8 %D
     22   %F = zext i8 %E to i32
     23   ret i32 %F
     24 ; CHECK: %D = add i32 %x, %y
     25 ; CHECK: %E = select i1 %cond, i32 %z, i32 %D
     26 ; CHECK: %F = and i32 %E, 255
     27 ; CHECK: ret i32 %F
     28 }
     29 
     30 define i8 @select2(i1 %cond, i8 %x, i8 %y, i8 %z) {
     31   %A = zext i8 %x to i32
     32   %B = zext i8 %y to i32
     33   %C = zext i8 %z to i32
     34   %D = add i32 %A, %B
     35   %E = select i1 %cond, i32 %C, i32 %D
     36   %F = trunc i32 %E to i8
     37   ret i8 %F
     38 ; CHECK: %D = add i8 %x, %y
     39 ; CHECK: %E = select i1 %cond, i8 %z, i8 %D
     40 ; CHECK: ret i8 %E
     41 }
     42