xref: /aosp_15_r20/external/llvm/test/Transforms/InstCombine/strcspn-2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test that the strcspn library call simplifier works correctly.
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -instcombine -S | FileCheck %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workertarget 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:64-S128"
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker@null = constant [1 x i8] zeroinitializer
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdeclare double @strcspn(i8*, i8*)
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker; Check that strcspn functions with the wrong prototype aren't simplified.
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerdefine double @test_no_simplify1(i8* %pat) {
14*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test_no_simplify1(
15*9880d681SAndroid Build Coastguard Worker  %str = getelementptr [1 x i8], [1 x i8]* @null, i32 0, i32 0
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Worker  %ret = call double @strcspn(i8* %str, i8* %pat)
18*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: call double @strcspn
19*9880d681SAndroid Build Coastguard Worker  ret double %ret
20*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret double %ret
21*9880d681SAndroid Build Coastguard Worker}
22