[all-commits] [llvm/llvm-project] b09b05: [M68k] Fix incorrect boolean content type (#152572)

Dan Salvato via All-commits all-commits at lists.llvm.org
Tue Aug 12 08:47:02 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b09b05a83ef781da8a967702488d10d4e5e6216d
      https://github.com/llvm/llvm-project/commit/b09b05a83ef781da8a967702488d10d4e5e6216d
  Author: Dan Salvato <dansalvato1 at gmail.com>
  Date:   2025-08-12 (Tue, 12 Aug 2025)

  Changed paths:
    M llvm/lib/Target/M68k/M68kISelLowering.cpp
    M llvm/lib/Target/M68k/M68kInstrArithmetic.td
    M llvm/test/CodeGen/M68k/Arith/add.ll
    M llvm/test/CodeGen/M68k/Arith/smul-with-overflow.ll
    M llvm/test/CodeGen/M68k/Atomics/rmw.ll
    M llvm/test/CodeGen/M68k/CodeModel/Large/Atomics/rmw.ll
    M llvm/test/CodeGen/M68k/Control/cmp.ll
    M llvm/test/CodeGen/M68k/Control/non-cmov-switch.ll
    M llvm/test/CodeGen/M68k/Control/setcc.ll

  Log Message:
  -----------
  [M68k] Fix incorrect boolean content type (#152572)

M68k's SETCC instruction (`scc`) distinctly fills the destination byte
with all 1s. If boolean contents are set to `ZeroOrOneBooleanContent`,
LLVM can mistakenly think the destination holds `0x01` instead of `0xff`
and emit broken code as a result. This change corrects the boolean
content type to `ZeroOrNegativeOneBooleanContent`.

For example, this IR:

```llvm
define dso_local signext range(i8 0, 2) i8 @testBool(i32 noundef %a) local_unnamed_addr #0 {
entry:
  %cmp = icmp eq i32 %a, 4660
  %. = zext i1 %cmp to i8
  ret i8 %.
}
```

would previously build as:

```asm
testBool:                               ; @testBool
	cmpi.l	#4660, (4,%sp)
	seq	%d0
	and.l	#255, %d0
	rts
```

Notice the `zext` is erroneously not clearing the low bits, and thus the
register returns with 255 instead of 1. This patch fixes the issue:

```asm
testBool:                               ; @testBool
	cmpi.l	#4660, (4,%sp)
	seq	%d0
	and.l	#1, %d0
	rts
```

Most of the tests containing `scc` suffered from the same value error as
described above, so those tests have been updated to match the new
output (which also logically corrects them).



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