[all-commits] [llvm/llvm-project] 398d68: [PPCMIPeephole] Fix incorrect compare elimination

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Apr 24 10:02:20 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 398d68f624d667a17727d346a2139a951a1ebce4
      https://github.com/llvm/llvm-project/commit/398d68f624d667a17727d346a2139a951a1ebce4
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-04-24 (Mon, 24 Apr 2023)

  Changed paths:
    M llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
    M llvm/test/CodeGen/PowerPC/cmp_elimination.ll

  Log Message:
  -----------
  [PPCMIPeephole] Fix incorrect compare elimination

D38236 moves a redundant compare instruction from the loop body to the
preheader.

It has a bug: when `MBB1 == &MBB2`, there may be only one compare instruction in the
loop. The code will lift the compare instruction to the preheader, failing to
account for the change of the compare result in a tail call, leading to a miscompile.

Suppress the compare elimination to fix https://github.com/llvm/llvm-project/issues/62294

Reviewed By: #powerpc, nemanjai

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




More information about the All-commits mailing list