[all-commits] [llvm/llvm-project] 316c07: [X86] Fix X86 conditional load/store optimization ...

azwolski via All-commits all-commits at lists.llvm.org
Wed Oct 15 06:47:32 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 316c0766942a1ed87e1a440efaa2fa4d0bad0418
      https://github.com/llvm/llvm-project/commit/316c0766942a1ed87e1a440efaa2fa4d0bad0418
  Author: azwolski <antoni.zwolski at intel.com>
  Date:   2025-10-15 (Wed, 15 Oct 2025)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/apx/cf.ll

  Log Message:
  -----------
  [X86] Fix X86 conditional load/store optimization for non-constant operands (#163353)

This PR fixes a bug in combineX86CloadCstore where an optimization was
being applied too broadly, causing incorrect code generation.

Without any assumptions about `X` this transformation is only valid when
`Y` is a non zero power of two/single-bit mask.
```cpp
      // res, flags2 = sub 0, (and (xor X, -1), Y)
      // cload/cstore ..., cond_ne, flag2
      // ->
      // res, flags2 = sub 0, (and X, Y)
      // cload/cstore ..., cond_e, flag2
```

We can restrict the optimization to most important case, so only apply
when `llvm::isOneConstant(Op1.getOperand(1))`. It might be not trivial
to find code that creates a SelectionDag with other values of `Y`.

Basline test: https://github.com/llvm/llvm-project/pull/163354



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