[all-commits] [llvm/llvm-project] 3b53c6: [Mips] Simplify isShiftedUIntAtAnyPosition (NFC)

kazutakahirata via All-commits all-commits at lists.llvm.org
Wed Jan 25 20:45:06 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3b53c6020052215be97898a4312fc41ca626a0ad
      https://github.com/llvm/llvm-project/commit/3b53c6020052215be97898a4312fc41ca626a0ad
  Author: Kazu Hirata <kazu at google.com>
  Date:   2023-01-25 (Wed, 25 Jan 2023)

  Changed paths:
    M llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

  Log Message:
  -----------
  [Mips] Simplify isShiftedUIntAtAnyPosition (NFC)

isShiftedUIntAtAnyPosition never gets zero as the argument because the
caller processes ImmValue satisfying isInt<16>(ImmValue), which
includes zero, long before it calls isShiftedUIntAtAnyPosition.

Given that the argument is always nonzero, findFirstSet is identical
to llvm::countr_zero.  Also, x == x >> BitNum << BitNum is always
true, so we are left with:

  isUInt<N>(x >> llvm::countr_zero(x))

Just in case the caller changes its behavior and starts passing zero
to us, we can protect the shift from undefined behavior "x << 64" by
adding "x &&".




More information about the All-commits mailing list