Index: llvm/test/Transforms/AggressiveInstCombine/strcmp.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/AggressiveInstCombine/strcmp.ll @@ -0,0 +1,29 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; TODO: Test that ... +; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s + +declare i32 @strcmp(ptr, ptr) + +@s1 = constant [2 x i8] c"0\00" + +; Fold strcmp(C, "x"). + +define i1 @fold_strcmp_s1_1(ptr %C) { +; CHECK-LABEL: @fold_strcmp_s1_1( +; CHECK-NEXT: [[CALL:%.*]] = call i32 @strcmp(ptr [[C:%.*]], ptr noundef @s1) +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[CALL]], 0 +; CHECK-NEXT: ret i1 [[CMP]] +; + %call = call i32 @strcmp(ptr %C, ptr noundef @s1) + %cmp = icmp eq i32 %call, 0 + ret i1 %cmp +} + +define i32 @fold_strcmp_s1_2(ptr %C) { +; CHECK-LABEL: @fold_strcmp_s1_2( +; CHECK-NEXT: [[CALL:%.*]] = call i32 @strcmp(ptr [[C:%.*]], ptr noundef @s1) +; CHECK-NEXT: ret i32 [[CALL]] +; + %call = call i32 @strcmp(ptr %C, ptr noundef @s1) + ret i32 %call +}