[all-commits] [llvm/llvm-project] 4e8317: [AVR] Expand shifts of all types except int8 and i...

Patryk Wychowaniec via All-commits all-commits at lists.llvm.org
Tue Jul 18 20:57:20 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4e831753b9cf8745e9bf251f775f2399c9ef4138
      https://github.com/llvm/llvm-project/commit/4e831753b9cf8745e9bf251f775f2399c9ef4138
  Author: Patryk Wychowaniec <pwychowaniec at pm.me>
  Date:   2023-07-19 (Wed, 19 Jul 2023)

  Changed paths:
    M llvm/lib/Target/AVR/AVRShiftExpand.cpp
    M llvm/test/CodeGen/AVR/shift-expand.ll
    M llvm/test/CodeGen/AVR/shift.ll

  Log Message:
  -----------
  [AVR] Expand shifts of all types except int8 and int16

Currently our AVRShiftExpand pass expands only 32-bit shifts, with the
assumption that other kinds of shifts (e.g. 64-bit ones) are
automatically reduced to 8-bit ones by LLVM during ISel.

However this is not always true and causes problems in the rust-lang runtime.

This commit changes the logic a bit, so that instead of expanding only
32-bit shifts, we expand shifts of all types except 8-bit and 16-bit.

This is not the most optimal solution, because 64-bit shifts can be
expanded to 32-bit shifts which has been deeply optimized.

I've checked the generated code using rustc + simavr, and all shifts
seem to behave correctly.

Spotted in the wild in rustc:
https://github.com/rust-lang/compiler-builtins/issues/523
https://github.com/rust-lang/rust/issues/112140

Reviewed By: benshi001

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




More information about the All-commits mailing list