HomePhabricator

MCSymbolicELF: simplify. (Flags & (x << s)) >> s is equivalent to Flags >> s & x
Audit Requiredbbd798f71c3d

Authored by MaskRay on Apr 10 2019, 3:30 AM.

Description

MCSymbolicELF: simplify. (Flags & (x << s)) >> s is equivalent to Flags >> s & x

llvm-svn: 358067

Details

Auditors
grosbach
Committed
MaskRayApr 10 2019, 3:30 AM
Parents
rGac590673637e: MCDwarf: use write_zeroes for MCDwarfLineAddr::FixedEncode
Branches
Unknown
Tags
Unknown

Event Timeline

This commit now requires audit.Apr 10 2019, 3:29 AM

@spatel maybe missing pattern in instcombine?

@spatel maybe missing pattern in instcombine?

This is hopefully just a readability improvement. We do manage to optimize the minimal case:

unsigned getOther(unsigned flags) {
  unsigned Other = (flags & (0x7 << 7)) >> 7;
  return Other << 5;
}
$ clang -O2 shsh.c -S -o - -emit-llvm
define i32 @getOther(i32) local_unnamed_addr #0 {
  %2 = lshr i32 %0, 2
  %3 = and i32 %2, 224
  ret i32 %3
}