[all-commits] [llvm/llvm-project] a111f9: [LoongArch][ISel] Check the number of sign bits i...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Mon Sep 9 18:20:01 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a111f9119a5ec77c19a514ec09454218f739454f
      https://github.com/llvm/llvm-project/commit/a111f9119a5ec77c19a514ec09454218f739454f
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2024-09-10 (Tue, 10 Sep 2024)

  Changed paths:
    M llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
    M llvm/test/CodeGen/LoongArch/ir-instruction/sdiv-udiv-srem-urem.ll

  Log Message:
  -----------
   [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)

After https://github.com/llvm/llvm-project/pull/92205, LoongArch ISel
selects `div.w` for `trunc i64 (sdiv i64 3202030857, (sext i32 X to
i64)) to i32`. It is incorrect since `3202030857` is not a signed 32-bit
constant. It will produce wrong result when `X == 2`:
https://alive2.llvm.org/ce/z/pzfGZZ

This patch adds additional `sexti32` checks to operands of
`PatGprGpr_32`.
Alive2 proof: https://alive2.llvm.org/ce/z/AkH5Mp

Fix #107414.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list