Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
sway
llvm source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
clang (assertions trunk)
clang (trunk)
clang 10.0.0
clang 10.0.1
clang 11.0.0
clang 11.0.1
clang 12.0.0
clang 12.0.1
clang 13.0.0
clang 14.0.0
clang 15.0.0
clang 16.0.0
clang 17.0.1
clang 18.1.0
clang 19.1.0
clang 20.1.0
clang 21.1.0
clang 4.0.1
clang 5.0.0
clang 6.0.0
clang 7.0.0
clang 8.0.0
clang 9.0.0
hexagon-clang 16.0.5
llc (assertions trunk)
llc (trunk)
llc 10.0.0
llc 10.0.1
llc 11.0.0
llc 11.0.1
llc 12.0.0
llc 12.0.1
llc 13.0.0
llc 14.0.0
llc 15.0.0
llc 16.0.0
llc 17.0.1
llc 18.1.0
llc 19.1.0
llc 20.1.0
llc 21.1.0
llc 3.2
llc 3.3
llc 3.9.1
llc 4.0.0
llc 4.0.1
llc 5.0.0
llc 6.0.0
llc 7.0.0
llc 8.0.0
llc 9.0.0
opt (assertions trunk)
opt (trunk)
opt 10.0.0
opt 10.0.1
opt 11.0.0
opt 11.0.1
opt 12.0.0
opt 12.0.1
opt 13.0.0
opt 14.0.0
opt 15.0.0
opt 16.0.0
opt 17.0.1
opt 18.1.0
opt 19.1.0
opt 20.1.0
opt 21.1.0
opt 3.2
opt 3.3
opt 3.9.1
opt 4.0.0
opt 4.0.1
opt 5.0.0
opt 6.0.0
opt 7.0.0
opt 8.0.0
opt 9.0.0
Options
Source code
declare void @show1() declare void @show2() declare void @show3() declare void @show4() @c = external global i32, align 4 define void @check1(i32 %x, i32 %y) { ; CHECK-LABEL: @check1( ; CHECK: br i1 %cmp, ; CHECK-NOT: br i1 %cmp, ; CHECK-NOT: if.else: ; Check that control-dependent-dce is able to infer the value of %cmp ; used at the end of basic block if.then and thus that the IR after ; control-dependent-dce contains only one conditional branch based on ; %cmp in basic block entry. entry: %cmp = icmp slt i32 %x, %y br i1 %cmp, label %if.then, label %if.end3 if.then: ; preds = %entry call void () @show1() br i1 %cmp, label %if.then2, label %if.else if.then2: ; preds = %if.then call void () @show2() br label %if.end if.else: ; preds = %if.then call void () @show3() br label %if.end if.end: ; preds = %if.else, %if.then2 br label %if.end3 if.end3: ; preds = %if.end, %entry ret void } define void @check2(i32 %x, i32 %y) { ; CHECK-LABEL: @check2( ; CHECK: br i1 %cmp, ; CHECK-NOT: br i1 %cmp, ; CHECK-NOT: if.else: ; Check that control-dependent-dce is able to infer the value of %cmp ; used at the end of basic block do.body in a loop and thus that the ; IR after control-dependent-dce contains only one conditional branch ; based on %cmp in basic block entry. entry: %cmp = icmp slt i32 %x, %y br i1 %cmp, label %if.then, label %if.end3 if.then: ; preds = %entry call void () @show1() br label %do.body do.body: ; preds = %do.cond, %if.then call void () @show2() br i1 %cmp, label %if.then2, label %if.else if.then2: ; preds = %do.body call void () @show3() br label %if.end if.else: ; preds = %do.body call void () @show4() br label %if.end if.end: ; preds = %if.else, %if.then2 %0 = load i32, i32* @c, align 4 %dec = add nsw i32 %0, -1 store i32 %dec, i32* @c, align 4 br label %do.cond do.cond: ; preds = %if.end %1 = load i32, i32* @c, align 4 %tobool = icmp ne i32 %1, 0 br i1 %tobool, label %do.body, label %do.end do.end: ; preds = %do.cond br label %if.end3 if.end3: ; preds = %do.end, %entry ret void }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree