|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 |
| 2 | +; RUN: opt %s -passes=instcombine -S | FileCheck %s |
| 3 | + |
| 4 | +define i32 @test_invert_bool(i32 %call, i32 %a) { |
| 5 | +; CHECK-LABEL: define i32 @test_invert_bool( |
| 6 | +; CHECK-SAME: i32 [[CALL:%.*]], i32 [[A:%.*]]) { |
| 7 | +; CHECK-NEXT: entry: |
| 8 | +; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[CALL]], 0 |
| 9 | +; CHECK-NEXT: call void @llvm.dbg.value(metadata i1 [[TOBOOL_NOT]], metadata [[META3:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_convert, 1, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg [[DBG8:![0-9]+]] |
| 10 | +; CHECK-NEXT: [[TMP0:%.*]] = and i32 [[A]], 1 |
| 11 | +; CHECK-NEXT: [[AND:%.*]] = select i1 [[TOBOOL_NOT]], i32 0, i32 [[TMP0]] |
| 12 | +; CHECK-NEXT: ret i32 [[AND]] |
| 13 | +; |
| 14 | +entry: |
| 15 | + %tobool = icmp ne i32 %call, 0 |
| 16 | + %land.ext = zext i1 %tobool to i32 |
| 17 | + call void @llvm.dbg.value(metadata i32 %land.ext, metadata !11, metadata !DIExpression()), !dbg !16 |
| 18 | + %and = and i32 %land.ext, %a |
| 19 | + ret i32 %and |
| 20 | +} |
| 21 | + |
| 22 | +declare void @llvm.dbg.value(metadata, metadata, metadata) |
| 23 | + |
| 24 | +!llvm.dbg.cu = !{!0} |
| 25 | +!llvm.module.flags = !{!10} |
| 26 | + |
| 27 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 28 | +!1 = !DIFile(filename: "test.c", directory: "/") |
| 29 | +!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 30 | +!10 = !{i32 2, !"Debug Info Version", i32 3} |
| 31 | +!11 = !DILocalVariable(name: "var", scope: !12, type: !5) |
| 32 | +!12 = distinct !DISubprogram(name: "test", scope: !1, file: !1, type: !13, unit: !0) |
| 33 | +!13 = !DISubroutineType(types: !14) |
| 34 | +!14 = !{null} |
| 35 | +!16 = !DILocation(scope: !12) |
0 commit comments