[all-commits] [llvm/llvm-project] 1259c0: [InstCombine] Canonicalize `switch(X << C)` into `...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Fri Jan 5 09:43:35 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1259c0512292a6559fb073b16056bff2e934822b
      https://github.com/llvm/llvm-project/commit/1259c0512292a6559fb073b16056bff2e934822b
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2024-01-06 (Sat, 06 Jan 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    A llvm/test/Transforms/InstCombine/switch-shl.ll

  Log Message:
  -----------
  [InstCombine] Canonicalize `switch(X << C)` into `switch(X)` (#77068)

This patch canonicalizes `switch(X << C)` to `switch(X)`. If the shift
may wrap, an and instruction will be created to mask out all of the
shifted bits.
Alive2: https://alive2.llvm.org/ce/z/wSsL5y

NOTE: We can relax the one-use constraint. But I don't see any benefit
in my benchmark.

Compile-time impact:
http://llvm-compile-time-tracker.com/compare.php?from=a776740d6296520b8bde156aa3f8d9ecb32cddd9&to=6dd783b9f90ae5f258102d732953567d7e317c02&stat=instructions%3Au

|stage1-O3|stage1-ReleaseThinLTO|stage1-ReleaseLTO-g|stage1-O0-g|stage2-O3|stage2-O0-g|stage2-clang|
|--|--|--|--|--|--|--|
|-0.00%|+0.01%|-0.02%|-0.01%|+0.02%|-0.00%|+0.01%|




More information about the All-commits mailing list