Thanks for using Compiler Explorer
Sponsors
C++
LLVM IR
Cppx
Cppx-Gold
Cppx-Blue
C
OpenCL C
C++ for OpenCL
Rust
D
Erlang
Go
ispc
Haskell
Java
Kotlin
Scala
OCaml
Python
Swift
Pascal
Fortran
Assembly
Analysis
CUDA C++
Zig
Clean
Ada
Nim
Crystal
C++ (Circle)
Ruby
CMake
C#
F#
Visual Basic
Dart
TypeScript
Solidity
llvm source #2
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
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 4.0.1
clang 5.0.0
clang 6.0.0
clang 7.0.0
clang 8.0.0
clang 9.0.0
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 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 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
; Original unoptimised function define i64 @fold_lshr_0(i1 %arg) { entry: %v0 = select i1 %arg, i64 64, i64 0 %v1 = lshr exact i64 %v0, 6 %v2 = xor i64 %v1, 1 %v3 = shl nuw i64 %v0, 57 %v4 = ashr exact i64 %v3, 63 %v5 = sub nsw i64 0, %v2 %v6 = and i64 %v5, 5369111591 %v7 = and i64 %v4, 5369111361 %v8 = add nuw nsw i64 %v7, %v6 ret i64 %v8 } ; Optimised function (with 'if (!I->hasOneUse()) return false;' disabled) define i64 @fold_lshr_1(i1 %arg) { entry: %v0 = zext i1 %arg to i64 %0 = or i64 %v0, 8589934590 %v2.neg = add nuw nsw i64 %0, 1 %v6 = and i64 %v2.neg, 5369111591 ret i64 %v6 } ; Test functions showing the differences with 'true' and 'false' input define i64 @orig_false() { %v0 = call i64 @fold_lshr_0(i1 false) ret i64 %v0 } define i64 @opt_false() { %v0 = call i64 @fold_lshr_1(i1 false) ret i64 %v0 } define i64 @orig_true() { %v0 = call i64 @fold_lshr_0(i1 true) ret i64 %v0 } define i64 @opt_true() { %v0 = call i64 @fold_lshr_1(i1 true) ret i64 %v0 }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree