[all-commits] [llvm/llvm-project] f88039: [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:47:24 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f8803919ad5c7e135af962efcbbe8c7c5310bbf4
      https://github.com/llvm/llvm-project/commit/f8803919ad5c7e135af962efcbbe8c7c5310bbf4
  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