[all-commits] [llvm/llvm-project] a80081: [SimplifyCFG] Avoid shifting by a too large exponent.

Florian Hahn via All-commits all-commits at lists.llvm.org
Fri Apr 29 07:19:34 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a80081763cb3792bf69ee95ee73c8754f1bfe074
      https://github.com/llvm/llvm-project/commit/a80081763cb3792bf69ee95ee73c8754f1bfe074
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2022-04-29 (Fri, 29 Apr 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    A llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-large-types.ll

  Log Message:
  -----------
  [SimplifyCFG] Avoid shifting by a too large exponent.

TI->getBitWidth can be > 64 and in those cases the shift will be UB due
to the exponent being too large.

To fix this, cap the shift at 63. I think this should work out fine,
because TableSize is itself a 64 bit type and the maximum table size
must fit in the type. Also, if we would underestimate the size here, at
most we get an extra ZExt.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D124608




More information about the All-commits mailing list