Home | History | Annotate | Download | only in InstSimplify
      1 ; RUN: opt < %s -instcombine -S | FileCheck %s
      2 ; Verify that the non-default calling conv doesn't prevent the libcall simplification
      3 
      4 @.str = private unnamed_addr constant [4 x i8] c"abc\00", align 1
      5 
      6 define arm_aapcscc i32 @_abs(i32 %i) nounwind readnone {
      7 ; CHECK: _abs
      8   %call = tail call arm_aapcscc i32 @abs(i32 %i) nounwind readnone
      9   ret i32 %call
     10 ; CHECK: %[[ISPOS:.*]] = icmp sgt i32 %i, -1
     11 ; CHECK: %[[NEG:.*]] = sub i32 0, %i
     12 ; CHECK: %[[RET:.*]] = select i1 %[[ISPOS]], i32 %i, i32 %[[NEG]]
     13 ; CHECK: ret i32 %[[RET]]
     14 }
     15 
     16 declare arm_aapcscc i32 @abs(i32) nounwind readnone
     17 
     18 define arm_aapcscc i32 @_labs(i32 %i) nounwind readnone {
     19 ; CHECK: _labs
     20   %call = tail call arm_aapcscc i32 @labs(i32 %i) nounwind readnone
     21   ret i32 %call
     22 ; CHECK: %[[ISPOS:.*]] = icmp sgt i32 %i, -1
     23 ; CHECK: %[[NEG:.*]] = sub i32 0, %i
     24 ; CHECK: %[[RET:.*]] = select i1 %[[ISPOS]], i32 %i, i32 %[[NEG]]
     25 ; CHECK: ret i32 %[[RET]]
     26 }
     27 
     28 declare arm_aapcscc i32 @labs(i32) nounwind readnone
     29 
     30 define arm_aapcscc i32 @_strlen1() {
     31 ; CHECK: _strlen1
     32   %call = tail call arm_aapcscc i32 @strlen(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0))
     33   ret i32 %call
     34 ; CHECK: ret i32 3
     35 }
     36 
     37 declare arm_aapcscc i32 @strlen(i8*)
     38 
     39 define arm_aapcscc zeroext i1 @_strlen2(i8* %str) {
     40 ; CHECK: _strlen2
     41   %call = tail call arm_aapcscc i32 @strlen(i8* %str)
     42   %cmp = icmp ne i32 %call, 0
     43   ret i1 %cmp
     44 
     45 ; CHECK: %[[STRLENFIRST:.*]] = load i8* %str
     46 ; CHECK: %[[CMP:.*]] = icmp ne i8 %[[STRLENFIRST]], 0
     47 ; CHECK: ret i1 %[[CMP]]
     48 }
     49