[llvm] [InstCombine] Avoid DeMorgan's on occasion (PR #109215)
Miguel Saldivar via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 16:03:49 PDT 2024
Saldivarcher wrote:
Here is what the assembly looks like with my changes:
```console
saldivar at pe34genoa ~/c/w/r/u/108731> cat repro.c
#include <stdint.h>
int64_t foo(int64_t w, int64_t x, int64_t y, int64_t z) {
int64_t s = w;
s &= ~(x & y);
s &= ~(z & ~y);
return s;
}
typedef uint8_t vec16u8 __attribute__((vector_size(16)));
vec16u8 fooVec(vec16u8 w, vec16u8 x, vec16u8 y, vec16u8 z) {
vec16u8 s = w;
s &= ~(x & y);
s &= ~(z & ~y);
return s;
}
saldivar at pe34genoa ~/c/w/r/u/108731> ~/workspace/work/llvm-project.git/build_debug/bin/clang repro.c -O3 -S -masm=intel -march=znver3
saldivar at pe34genoa ~/c/w/r/u/108731> cat repro.s
.text
.intel_syntax noprefix
.file "repro.c"
.globl foo # -- Begin function foo
.p2align 4, 0x90
.type foo, at function
foo: # @foo
.cfi_startproc
# %bb.0: # %entry
and rsi, rdx
andn rcx, rdx, rcx
andn rax, rsi, rdi
andn rax, rcx, rax
ret
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.cfi_endproc
# -- End function
.globl fooVec # -- Begin function fooVec
.p2align 4, 0x90
.type fooVec, at function
fooVec: # @fooVec
.cfi_startproc
# %bb.0: # %entry
vandps xmm1, xmm2, xmm1
vandnps xmm2, xmm2, xmm3
vandnps xmm0, xmm1, xmm0
vandnps xmm0, xmm2, xmm0
ret
.Lfunc_end1:
.size fooVec, .Lfunc_end1-fooVec
.cfi_endproc
# -- End function
.ident "clang version 20.0.0git (git at github.com:llvm/llvm-project.git f00c946c2da0caf6da4a49e87ac905a8b1d2e8b6)"
.section ".note.GNU-stack","", at progbits
.addrsig
```
https://github.com/llvm/llvm-project/pull/109215
More information about the llvm-commits
mailing list