- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
Closed
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization
Description
C++ example
#include <stdint.h>
using u32 = uint32_t;
auto inline in_range(auto x, auto lo, auto hi) -> bool {
    return lo <= x && x <= hi;
}
extern "C" {
auto src(u32 c) -> bool { return (c == 0x7f) || in_range(c, 0x80, 0x9f); }
auto tgt(u32 c) -> bool { return in_range(c, 0x7f, 0x9f); }
}gives
src:
        mov     w8, #128
        cmp     w0, #127
        and     w9, w0, #0xffffffe0
        ccmp    w9, w8, #4, ne
        cset    w0, eq
        ret
tgt:
        sub     w8, w0, #127
        cmp     w8, #33
        cset    w0, lo
        retAlive proof
define dso_local noundef i1 @src(i32 noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq i32 %0, 127
  %3 = and i32 %0, -32
  %4 = icmp eq i32 %3, 128
  %5 = or i1 %2, %4
  ret i1 %5
}
define dso_local noundef i1 @tgt(i32 noundef %0) local_unnamed_addr #0 {
  %2 = add i32 %0, -127
  %3 = icmp ult i32 %2, 33
  ret i1 %3
}Motivation
dtcxzyw
Metadata
Metadata
Assignees
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization