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
Clojure
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
Helion
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
Yul (Solidity IR)
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
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-grtev4-linux-gnu" define noundef zeroext i8 @foo(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 align 32 !prof !42 { %3 = sext i32 %1 to i64 %4 = getelementptr inbounds nuw i8, ptr %0, i64 23 %5 = load i8, ptr %4, align 1 %6 = icmp slt i8 %5, 0 %7 = getelementptr inbounds nuw i8, ptr %0, i64 8 %8 = load i64, ptr %7, align 8 %9 = zext nneg i8 %5 to i64 %10 = select i1 %6, i64 %8, i64 %9 %.not.i = icmp ult i64 %10, %3 br i1 %.not.i, label %out_of_bounds, label %in_bounds, !prof !56 out_of_bounds: call void @llvm.trap() unreachable in_bounds: %buf = load ptr, ptr %0, align 8 %spec.select.i = select i1 %6, ptr %buf, ptr %0 %.0.i = getelementptr inbounds nuw i8, ptr %spec.select.i, i64 %3 %val = load i8, ptr %.0.i, align 1 ret i8 %val } define noundef zeroext i8 @expected(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 align 32 !prof !42 { %3 = sext i32 %1 to i64 %4 = getelementptr inbounds nuw i8, ptr %0, i64 23 %5 = load i8, ptr %4, align 1 %6 = icmp slt i8 %5, 0 %7 = getelementptr inbounds nuw i8, ptr %0, i64 8 %8 = load i64, ptr %7, align 8 %9 = zext nneg i8 %5 to i64 %10 = select i1 %6, i64 %8, i64 %9 %buf = load ptr, ptr %0, align 8 %spec.select.i = select i1 %6, ptr %buf, ptr %0 %.not.i = icmp ult i64 %10, %3 br i1 %.not.i, label %out_of_bounds, label %in_bounds, !prof !56 out_of_bounds: call void @llvm.trap() unreachable in_bounds: %.0.i = getelementptr inbounds nuw i8, ptr %spec.select.i, i64 %3 %val = load i8, ptr %.0.i, align 1 ret i8 %val } declare void @llvm.trap() #2 attributes #2 = { cold noreturn nounwind memory(inaccessiblemem: write) } !9 = !{i32 1, !"ProfileSummary", !10} !10 = !{!11, !12, !13, !14, !15, !16, !17, !18, !19, !20} !11 = !{!"ProfileFormat", !"SampleProfile"} !12 = !{!"TotalCount", i64 417858463400} !13 = !{!"MaxCount", i64 946115141} !14 = !{!"MaxInternalCount", i64 0} !15 = !{!"MaxFunctionCount", i64 854277961} !16 = !{!"NumCounts", i64 107385147} !17 = !{!"NumFunctions", i64 598450} !18 = !{!"IsPartialProfile", i64 1} !19 = !{!"PartialProfileRatio", double 0.000000e+00} !20 = !{!"DetailedSummary", !21} !21 = !{!22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37} !22 = !{i32 10000, i64 763074472, i32 6} !23 = !{i32 100000, i64 500868894, i32 75} !24 = !{i32 200000, i64 151236416, i32 259} !25 = !{i32 300000, i64 42289166, i32 900} !26 = !{i32 400000, i64 12450809, i32 2721} !27 = !{i32 500000, i64 4113944, i32 8764} !28 = !{i32 600000, i64 1458085, i32 26555} !29 = !{i32 700000, i64 406496, i32 83764} !30 = !{i32 800000, i64 92473, i32 314957} !31 = !{i32 900000, i64 14724, i32 1549481} !32 = !{i32 950000, i64 3921, i32 4389630} !33 = !{i32 990000, i64 474, i32 16333677} !34 = !{i32 999000, i64 53, i32 36691153} !35 = !{i32 999900, i64 9, i32 51373515} !36 = !{i32 999990, i64 2, i32 59600451} !37 = !{i32 999999, i64 1, i32 61994455} !42 = !{!"function_entry_count", i64 -1} !56 = !{!"branch_weights", !"expected", i32 1, i32 2000}
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