[all-commits] [llvm/llvm-project] 1aa917: [DAGCombiner] Pre-commit test case for miscompile ...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Thu Apr 25 09:55:22 PDT 2024


  Branch: refs/heads/release/18.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 1aa91720cc4fa1511c0851269babb40a05401193
      https://github.com/llvm/llvm-project/commit/1aa91720cc4fa1511c0851269babb40a05401193
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2024-04-25 (Thu, 25 Apr 2024)

  Changed paths:
    M llvm/test/CodeGen/X86/shift-combine.ll

  Log Message:
  -----------
  [DAGCombiner] Pre-commit test case for miscompile bug in combineShiftOfShiftedLogic

DAGCombiner is trying to fold shl over binops, and in the process
combining it with another shl. However it needs to be more careful
to ensure that the sum of the shift counts fits in the type used
for the shift amount.
For example, X86 is using i8 as shift amount type. So we need to
make sure that the sum of the shift amounts isn't greater than 255.

Fix will be applied in a later commit. This only pre-commits the
test case to show that we currently get the wrong result.

Bug was found when testing the C23 BitInt feature.

(cherry picked from commit 5fd9bbdea6cc248469d5465de44e747378ffafcb)


  Commit: 78b99c73ee4b96fe9ce0e294d4632326afb2db42
      https://github.com/llvm/llvm-project/commit/78b99c73ee4b96fe9ce0e294d4632326afb2db42
  Author: Björn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2024-04-25 (Thu, 25 Apr 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/test/CodeGen/X86/shift-combine.ll

  Log Message:
  -----------
  [DAGCombiner] Fix miscompile bug in combineShiftOfShiftedLogic (#89616)

Ensure that the sum of the shift amounts does not overflow the
shift amount type when combining shifts in combineShiftOfShiftedLogic.

Solves a miscompile bug found when testing the C23 BitInt feature.

Targets like X86 that only use an i8 for shift amounts after
legalization seems to be extra susceptible for bugs like this as it
isn't legal to shift more than 255 steps.

(cherry picked from commit f9b419b7a038dcd51a7943b160acc867714c595f)


Compare: https://github.com/llvm/llvm-project/compare/35fea1032741...78b99c73ee4b

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