[all-commits] [llvm/llvm-project] aff1ba: [X86] Fix null dereference in optimizeCompareInstr...

tfzee via All-commits all-commits at lists.llvm.org
Tue Sep 22 04:58:42 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aff1ba103ab3006242c72af33420a3437f4ff1db
      https://github.com/llvm/llvm-project/commit/aff1ba103ab3006242c72af33420a3437f4ff1db
  Author: tfzee <tim.ziegler at intel.com>
  Date:   2026-09-22 (Tue, 22 Sep 2026)

  Changed paths:
    M llvm/lib/Target/X86/X86InstrInfo.cpp
    A llvm/test/CodeGen/X86/lzcnt-cmp-null-deref.mir

  Log Message:
  -----------
  [X86] Fix null dereference in optimizeCompareInstr after lzcnt/tzcnt (#224282)

#210069 added `LTZCNTInst` to the exit condition of the backward scan of
`optimizeCompareInstr()`:

```c++
    if (MI || Sub || LTZCNTInst)
      break;
```

but it assigns `MI = LTZCNTInst` only inside the *forward* scan's
"EFLAGS is
used by this instruction" branch. When the forward scan never reaches
that
branch, both `MI` and `Sub` stay null.
However later code was built on the idea that one of them is not null.
 
Added a MIR test that would crash before but gets fixed by this
additional check.

Used AI for code review and comment/PR/test formatting/writing



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