[all-commits] [llvm/llvm-project] 268371: [RISCV] Add test case for miscompile caused by tre...

Craig Topper via All-commits all-commits at lists.llvm.org
Sat Mar 19 18:43:47 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 268371cf7b9f6fd3b9320564f1abd3615eecd2e8
      https://github.com/llvm/llvm-project/commit/268371cf7b9f6fd3b9320564f1abd3615eecd2e8
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2022-03-19 (Sat, 19 Mar 2022)

  Changed paths:
    M llvm/test/CodeGen/RISCV/aext-to-sext.ll

  Log Message:
  -----------
  [RISCV] Add test case for miscompile caused by treating ANY_EXTEND of constants as SIGN_EXTEND.

The code that inserts AssertZExt based on predecessor information assumes
constants are zero extended for phi incoming values this allows
AssertZExt to be created in blocks consuming a Phi.
SelectionDAG::getNode treats any_extend of i32 constants as sext for RISCV.
The code that creates phi incoming values in the predecessors creates an
any_extend for the constants which then gets treated as a sext by getNode.
This makes the AssertZExt incorrect and can cause zexts to be
incorrectly removed.

This bug was introduced by D105918

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


  Commit: 4eb59f017903c8b70b5c5aad892bdc73516a6766
      https://github.com/llvm/llvm-project/commit/4eb59f017903c8b70b5c5aad892bdc73516a6766
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2022-03-19 (Sat, 19 Mar 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/test/CodeGen/RISCV/aext-to-sext.ll

  Log Message:
  -----------
  [SelectionDAG][RISCV] Make RegsForValue::getCopyToRegs explicitly zero_extend constants.

ComputePHILiveOutRegInfo assumes that constant incoming values to
Phis will be zero extended if they aren't a legal type. To guarantee
that we should zero_extend rather than any_extend constants.

This fixes a bug for RISCV where any_extend of constants can be
treated as a sign_extend.

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


Compare: https://github.com/llvm/llvm-project/compare/983ed87c6175...4eb59f017903


More information about the All-commits mailing list