[all-commits] [llvm/llvm-project] da11d2: [SystemZ] Clear NW flags on an ISD::SUB when reuse...

Jonas Paulsson via All-commits all-commits at lists.llvm.org
Tue Mar 14 11:45:09 PDT 2023


  Branch: refs/heads/CmpNW
  Home:   https://github.com/llvm/llvm-project
  Commit: da11d2aaa7b7e89e33cda733e3299ece1efa2cdc
      https://github.com/llvm/llvm-project/commit/da11d2aaa7b7e89e33cda733e3299ece1efa2cdc
  Author: Jonas Paulsson <paulsson at linux.vnet.ibm.com>
  Date:   2023-03-14 (Tue, 14 Mar 2023)

  Changed paths:
    M llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
    A llvm/test/CodeGen/SystemZ/int-cmp-62.ll

  Log Message:
  -----------
  [SystemZ] Clear NW flags on an ISD::SUB when reused as comparison.

The SystemZ backend will try to reuse an existing subtraction of two values
whenever they are to be compared for equality. This depends on the SystemZ
subtraction instruction setting the condition code, which can also signal
overflow.

A later pass will remove the compare and reuse the CC from the subtraction
directly. However, if that subtraction has the NSW flag set it will not
include the overflow bit in the updated CC user. That was a bug which can
lead to wrong results, as shown by a csmith program.

Fixes: https://github.com/llvm/llvm-project/issues/61268

Reviewed By: nikic, uweigand

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




More information about the All-commits mailing list