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

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Mon Sep 16 11:29:59 PDT 2024


  Branch: refs/heads/release/19.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 78654faa0c6d9dc2f72b81953b9cffbb7675755b
      https://github.com/llvm/llvm-project/commit/78654faa0c6d9dc2f72b81953b9cffbb7675755b
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2024-09-16 (Mon, 16 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.

(cherry picked from commit a111f9119a5ec77c19a514ec09454218f739454f)



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