[llvm] [DAGCombine] Fold any-extend(and(trunc(x), C)) -> and(x, C) on X86 (PR #200052)
Aayush Shrivastava via llvm-commits
llvm-commits at lists.llvm.org
Thu May 28 05:04:00 PDT 2026
https://github.com/iamaayushrivastava updated https://github.com/llvm/llvm-project/pull/200052
>From 840f97bf6c1b20e17d34a7c5d63763173f335412 Mon Sep 17 00:00:00 2001
From: iamaayushrivastava <iamaayushrivastava at gmail.com>
Date: Thu, 28 May 2026 02:27:37 +0530
Subject: [PATCH 1/2] [DAGCombine] Fold any-extend(and(trunc(x), C)) -> and(x,
C) on X86
---
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 10 +--
llvm/test/CodeGen/X86/aext-and-trunc-fold.ll | 77 +++++++++++++++++++
2 files changed, 82 insertions(+), 5 deletions(-)
create mode 100644 llvm/test/CodeGen/X86/aext-and-trunc-fold.ll
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 2a9ecebeb1508..bac76620fc77d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -16163,15 +16163,15 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) {
return DAG.getAnyExtOrTrunc(N0.getOperand(0), DL, VT);
// Fold (aext (and (trunc x), cst)) -> (and x, cst)
- // if the trunc is not free.
+ // if either of the casts is not free.
if (N0.getOpcode() == ISD::AND &&
N0.getOperand(0).getOpcode() == ISD::TRUNCATE &&
N0.getOperand(1).getOpcode() == ISD::Constant &&
- !TLI.isTruncateFree(N0.getOperand(0).getOperand(0), N0.getValueType())) {
+ (!TLI.isTruncateFree(N0.getOperand(0).getOperand(0), N0.getValueType()) ||
+ !TLI.isZExtFree(N0.getValueType(), VT))) {
SDValue X = DAG.getAnyExtOrTrunc(N0.getOperand(0).getOperand(0), DL, VT);
- SDValue Y = DAG.getNode(ISD::ANY_EXTEND, DL, VT, N0.getOperand(1));
- assert(isa<ConstantSDNode>(Y) && "Expected constant to be folded!");
- return DAG.getNode(ISD::AND, DL, VT, X, Y);
+ APInt Mask = N0.getConstantOperandAPInt(1).zext(VT.getSizeInBits());
+ return DAG.getNode(ISD::AND, DL, VT, X, DAG.getConstant(Mask, DL, VT));
}
// fold (aext (load x)) -> (aext (truncate (extload x)))
diff --git a/llvm/test/CodeGen/X86/aext-and-trunc-fold.ll b/llvm/test/CodeGen/X86/aext-and-trunc-fold.ll
new file mode 100644
index 0000000000000..71d5b0aba250b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/aext-and-trunc-fold.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefix=X86
+
+; Test for GH#195575: fold (aext (and (trunc x) C)) -> (and x C)
+; when either the truncate or zero-extend is not free.
+; Previously visitANY_EXTEND only checked isTruncateFree (which is true on X86
+; for i32->i8), missing the case where isZExtFree is false (i8->i32 on X86).
+; This caused "and al, 7; movzx eax, al" instead of the optimal "and eax, 7".
+;
+; The DAGCombiner converts zero_extend to any_extend when the result is only
+; used by a shift (upper bits don't affect the output), but visitANY_EXTEND
+; was then failing to fold the (aext (and (trunc x) C)) pattern on X86 because
+; isTruncateFree(i32->i8) is true there. Adding the isZExtFree check (which is
+; false for i8->i32 on X86) makes the fold fire correctly.
+
+; Pattern that directly triggers the bug: shl context converts zext->aext before
+; the fold can run, and then visitANY_EXTEND needs the isZExtFree check.
+define i32 @aext_and_trunc_shl(i32 %x) {
+; X64-LABEL: aext_and_trunc_shl:
+; X64: # %bb.0:
+; X64-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-NEXT: andl $7, %edi
+; X64-NEXT: leal (%rdi,%rdi), %eax
+; X64-NEXT: retq
+;
+; X86-LABEL: aext_and_trunc_shl:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: andl $7, %eax
+; X86-NEXT: addl %eax, %eax
+; X86-NEXT: retl
+ %trunc = trunc i32 %x to i8
+ %and = and i8 %trunc, 7
+ %zext = zext i8 %and to i32
+ %shl = shl i32 %zext, 1
+ ret i32 %shl
+}
+
+; Basic (aext (and (trunc i32) C)) -> (and i32 C) pattern.
+define i32 @aext_and_trunc_i32(i32 %x) {
+; X64-LABEL: aext_and_trunc_i32:
+; X64: # %bb.0:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: andl $7, %eax
+; X64-NEXT: retq
+;
+; X86-LABEL: aext_and_trunc_i32:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: andl $7, %eax
+; X86-NEXT: retl
+ %trunc = trunc i32 %x to i8
+ %and = and i8 %trunc, 7
+ %zext = zext i8 %and to i32
+ ret i32 %zext
+}
+
+; (aext (and (trunc i64) C)) -> (and i32 C) on x86-64.
+define i32 @aext_and_trunc_i64(i64 %x) {
+; X64-LABEL: aext_and_trunc_i64:
+; X64: # %bb.0:
+; X64-NEXT: movq %rdi, %rax
+; X64-NEXT: andl $15, %eax
+; X64-NEXT: # kill: def $eax killed $eax killed $rax
+; X64-NEXT: retq
+;
+; X86-LABEL: aext_and_trunc_i64:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: andl $15, %eax
+; X86-NEXT: retl
+ %trunc = trunc i64 %x to i8
+ %and = and i8 %trunc, 15
+ %zext = zext i8 %and to i32
+ ret i32 %zext
+}
>From a90e72cf5b2a2e72cb0c605f519cf2529292ef52 Mon Sep 17 00:00:00 2001
From: iamaayushrivastava <iamaayushrivastava at gmail.com>
Date: Thu, 28 May 2026 17:31:36 +0530
Subject: [PATCH 2/2] [DAGCombine] Regenerate tests affected by fold
any-extend(and(trunc(x), C))
---
llvm/test/CodeGen/AArch64/bitfield-insert.ll | 2 +-
llvm/test/CodeGen/AArch64/bswap-known-bits.ll | 2 +-
llvm/test/CodeGen/AArch64/sshl_sat.ll | 2 +-
llvm/test/CodeGen/AArch64/ushl_sat.ll | 2 +-
llvm/test/CodeGen/RISCV/and.ll | 9 ++++---
llvm/test/CodeGen/RISCV/pr142004.ll | 4 ++-
llvm/test/CodeGen/RISCV/zbb-logic-neg-imm.ll | 25 ++++++++++++++----
llvm/test/CodeGen/X86/and-with-overflow.ll | 4 +--
llvm/test/CodeGen/X86/combine-srem.ll | 4 +--
llvm/test/CodeGen/X86/llvm.frexp.ll | 4 +--
llvm/test/CodeGen/X86/masked_load.ll | 26 +++++++++----------
llvm/test/CodeGen/X86/masked_store.ll | 2 +-
...asked-merge-scalar-constmask-innerouter.ll | 4 +--
...-merge-scalar-constmask-interleavedbits.ll | 4 +--
...-scalar-constmask-interleavedbytehalves.ll | 4 +--
...d-masked-merge-scalar-constmask-lowhigh.ll | 4 +--
16 files changed, 61 insertions(+), 41 deletions(-)
diff --git a/llvm/test/CodeGen/AArch64/bitfield-insert.ll b/llvm/test/CodeGen/AArch64/bitfield-insert.ll
index eefb862c5313c..9402aa367ef2b 100644
--- a/llvm/test/CodeGen/AArch64/bitfield-insert.ll
+++ b/llvm/test/CodeGen/AArch64/bitfield-insert.ll
@@ -739,7 +739,7 @@ define i32 @orr_not_bfxil_test2_i32(i32 %0) {
define i16 @implicit_trunc_of_imm(ptr %p, i16 %a, i16 %b) {
; CHECK-LABEL: implicit_trunc_of_imm:
; CHECK: // %bb.0: // %entry
-; CHECK-NEXT: and w8, w1, #0xffffe000
+; CHECK-NEXT: and w8, w1, #0xe000
; CHECK-NEXT: mov x9, x0
; CHECK-NEXT: mov w10, w8
; CHECK-NEXT: mov w0, w8
diff --git a/llvm/test/CodeGen/AArch64/bswap-known-bits.ll b/llvm/test/CodeGen/AArch64/bswap-known-bits.ll
index 7e881198ced02..b42cf9db7bd01 100644
--- a/llvm/test/CodeGen/AArch64/bswap-known-bits.ll
+++ b/llvm/test/CodeGen/AArch64/bswap-known-bits.ll
@@ -131,7 +131,7 @@ define i16 @bswap_src_and_lo_i16(i16 %x) {
define i16 @bswap_src_and_hi_i16(i16 %x) {
; CHECK-LABEL: bswap_src_and_hi_i16:
; CHECK: ; %bb.0:
-; CHECK-NEXT: and w8, w0, #0xffffff00
+; CHECK-NEXT: and w8, w0, #0xff00
; CHECK-NEXT: rev16 w0, w8
; CHECK-NEXT: ret
%m = and i16 %x, 65280
diff --git a/llvm/test/CodeGen/AArch64/sshl_sat.ll b/llvm/test/CodeGen/AArch64/sshl_sat.ll
index be2b3e763733b..e68b1f090949f 100644
--- a/llvm/test/CodeGen/AArch64/sshl_sat.ll
+++ b/llvm/test/CodeGen/AArch64/sshl_sat.ll
@@ -131,7 +131,7 @@ define void @combine_shlsat_vector() nounwind {
define i16 @combine_shlsat_to_shl(i16 %x) nounwind {
; CHECK-LABEL: combine_shlsat_to_shl:
; CHECK: // %bb.0:
-; CHECK-NEXT: and w0, w0, #0xfffffffc
+; CHECK-NEXT: and w0, w0, #0xfffc
; CHECK-NEXT: ret
%x2 = ashr i16 %x, 2
%tmp = call i16 @llvm.sshl.sat.i16(i16 %x2, i16 2)
diff --git a/llvm/test/CodeGen/AArch64/ushl_sat.ll b/llvm/test/CodeGen/AArch64/ushl_sat.ll
index 870f80545f999..ac28a3dfbd168 100644
--- a/llvm/test/CodeGen/AArch64/ushl_sat.ll
+++ b/llvm/test/CodeGen/AArch64/ushl_sat.ll
@@ -117,7 +117,7 @@ define void @combine_shlsat_vector() nounwind {
define i16 @combine_shlsat_to_shl(i16 %x) nounwind {
; CHECK-LABEL: combine_shlsat_to_shl:
; CHECK: // %bb.0:
-; CHECK-NEXT: and w0, w0, #0xfffffffc
+; CHECK-NEXT: and w0, w0, #0xfffc
; CHECK-NEXT: ret
%x2 = lshr i16 %x, 2
%tmp = call i16 @llvm.ushl.sat.i16(i16 %x2, i16 2)
diff --git a/llvm/test/CodeGen/RISCV/and.ll b/llvm/test/CodeGen/RISCV/and.ll
index 31c63c7f9b18f..2b0b10ac57ff6 100644
--- a/llvm/test/CodeGen/RISCV/and.ll
+++ b/llvm/test/CodeGen/RISCV/and.ll
@@ -99,8 +99,8 @@ define i32 @and32_0xfffff000(i32 %x) {
;
; RV64I-LABEL: and32_0xfffff000:
; RV64I: # %bb.0:
-; RV64I-NEXT: lui a1, 1048575
-; RV64I-NEXT: and a0, a0, a1
+; RV64I-NEXT: srliw a0, a0, 12
+; RV64I-NEXT: slli a0, a0, 12
; RV64I-NEXT: ret
%a = and i32 %x, -4096
ret i32 %a
@@ -114,7 +114,10 @@ define i32 @and32_0xfffffa00(i32 %x) {
;
; RV64I-LABEL: and32_0xfffffa00:
; RV64I: # %bb.0:
-; RV64I-NEXT: andi a0, a0, -1536
+; RV64I-NEXT: li a1, 1
+; RV64I-NEXT: slli a1, a1, 32
+; RV64I-NEXT: addi a1, a1, -1536
+; RV64I-NEXT: and a0, a0, a1
; RV64I-NEXT: ret
%a = and i32 %x, -1536
ret i32 %a
diff --git a/llvm/test/CodeGen/RISCV/pr142004.ll b/llvm/test/CodeGen/RISCV/pr142004.ll
index 709644e49e704..49173ca11d059 100644
--- a/llvm/test/CodeGen/RISCV/pr142004.ll
+++ b/llvm/test/CodeGen/RISCV/pr142004.ll
@@ -11,12 +11,14 @@ define i32 @foo(i32 %x) {
; CHECK-NEXT: lui a1, %hi(f)
; CHECK-NEXT: lui a2, %hi(d)
; CHECK-NEXT: lbu a1, %lo(f)(a1)
-; CHECK-NEXT: lhu a2, %lo(d)(a2)
+; CHECK-NEXT: ld a2, %lo(d)(a2)
; CHECK-NEXT: slli a0, a0, 48
; CHECK-NEXT: srli a3, a0, 48
; CHECK-NEXT: xori a0, a1, 255
; CHECK-NEXT: or a0, a0, a2
; CHECK-NEXT: lui a1, %hi(e)
+; CHECK-NEXT: slli a0, a0, 48
+; CHECK-NEXT: srli a0, a0, 48
; CHECK-NEXT: sw a3, %lo(e)(a1)
; CHECK-NEXT: ret
entry:
diff --git a/llvm/test/CodeGen/RISCV/zbb-logic-neg-imm.ll b/llvm/test/CodeGen/RISCV/zbb-logic-neg-imm.ll
index 751b05ebdba2a..e57a47e9bc0c0 100644
--- a/llvm/test/CodeGen/RISCV/zbb-logic-neg-imm.ll
+++ b/llvm/test/CodeGen/RISCV/zbb-logic-neg-imm.ll
@@ -9,11 +9,26 @@
; RUN: | FileCheck %s --check-prefixes=CHECK,RV64,ZBS,ZBS64
define i32 @and0xabcdefff(i32 %x) {
-; CHECK-LABEL: and0xabcdefff:
-; CHECK: # %bb.0:
-; CHECK-NEXT: lui a1, 344865
-; CHECK-NEXT: andn a0, a0, a1
-; CHECK-NEXT: ret
+; RV32-LABEL: and0xabcdefff:
+; RV32: # %bb.0:
+; RV32-NEXT: lui a1, 344865
+; RV32-NEXT: andn a0, a0, a1
+; RV32-NEXT: ret
+;
+; NOZBS64-LABEL: and0xabcdefff:
+; NOZBS64: # %bb.0:
+; NOZBS64-NEXT: lui a1, 1048404
+; NOZBS64-NEXT: addi a1, a1, 801
+; NOZBS64-NEXT: slli a1, a1, 12
+; NOZBS64-NEXT: andn a0, a0, a1
+; NOZBS64-NEXT: ret
+;
+; ZBS64-LABEL: and0xabcdefff:
+; ZBS64: # %bb.0:
+; ZBS64-NEXT: lui a1, 869153
+; ZBS64-NEXT: bclri a1, a1, 31
+; ZBS64-NEXT: andn a0, a0, a1
+; ZBS64-NEXT: ret
%and = and i32 %x, -1412567041
ret i32 %and
}
diff --git a/llvm/test/CodeGen/X86/and-with-overflow.ll b/llvm/test/CodeGen/X86/and-with-overflow.ll
index a63f6cc6ea7e2..1fef4165f0591 100644
--- a/llvm/test/CodeGen/X86/and-with-overflow.ll
+++ b/llvm/test/CodeGen/X86/and-with-overflow.ll
@@ -21,8 +21,8 @@ define i8 @and_i8_ri(i8 zeroext %0, i8 zeroext %1) {
; X64-LABEL: and_i8_ri:
; X64: # %bb.0:
; X64-NEXT: movl %edi, %eax
-; X64-NEXT: andb $-17, %al
-; X64-NEXT: movzbl %al, %eax
+; X64-NEXT: andl $-17, %eax
+; X64-NEXT: testb $-17, %dil
; X64-NEXT: cmovel %edi, %eax
; X64-NEXT: # kill: def $al killed $al killed $eax
; X64-NEXT: retq
diff --git a/llvm/test/CodeGen/X86/combine-srem.ll b/llvm/test/CodeGen/X86/combine-srem.ll
index 0ca79adf5392e..82ac096353f06 100644
--- a/llvm/test/CodeGen/X86/combine-srem.ll
+++ b/llvm/test/CodeGen/X86/combine-srem.ll
@@ -498,7 +498,7 @@ define i16 @combine_i16_srem_pow2(i16 %x) {
; CHECK-NEXT: leal 15(%rax), %ecx
; CHECK-NEXT: testw %ax, %ax
; CHECK-NEXT: cmovnsl %edi, %ecx
-; CHECK-NEXT: andl $-16, %ecx
+; CHECK-NEXT: andl $65520, %ecx # imm = 0xFFF0
; CHECK-NEXT: subl %ecx, %eax
; CHECK-NEXT: # kill: def $ax killed $ax killed $rax
; CHECK-NEXT: retq
@@ -513,7 +513,7 @@ define i16 @combine_i16_srem_negpow2(i16 %x) {
; CHECK-NEXT: leal 255(%rax), %ecx
; CHECK-NEXT: testw %ax, %ax
; CHECK-NEXT: cmovnsl %edi, %ecx
-; CHECK-NEXT: andl $-256, %ecx
+; CHECK-NEXT: andl $65280, %ecx # imm = 0xFF00
; CHECK-NEXT: subl %ecx, %eax
; CHECK-NEXT: # kill: def $ax killed $ax killed $rax
; CHECK-NEXT: retq
diff --git a/llvm/test/CodeGen/X86/llvm.frexp.ll b/llvm/test/CodeGen/X86/llvm.frexp.ll
index e3a1b1b83b2e3..9112c176eaf27 100644
--- a/llvm/test/CodeGen/X86/llvm.frexp.ll
+++ b/llvm/test/CodeGen/X86/llvm.frexp.ll
@@ -25,7 +25,7 @@ define { half, i32 } @test_frexp_f16_i32(half %a) nounwind {
; X64-NEXT: cmpl $1024, %esi # imm = 0x400
; X64-NEXT: cmovael %eax, %edi
; X64-NEXT: addl $-14, %edi
-; X64-NEXT: andl $-31745, %ecx # imm = 0x83FF
+; X64-NEXT: andl $33791, %ecx # imm = 0x83FF
; X64-NEXT: orl $14336, %ecx # imm = 0x3800
; X64-NEXT: addl $-31744, %esi # imm = 0x8400
; X64-NEXT: movzwl %si, %esi
@@ -76,7 +76,7 @@ define half @test_frexp_f16_i32_only_use_fract(half %a) nounwind {
; X64-NEXT: andl $32767, %edx # imm = 0x7FFF
; X64-NEXT: cmpl $1024, %edx # imm = 0x400
; X64-NEXT: cmovael %ecx, %eax
-; X64-NEXT: andl $-31745, %eax # imm = 0x83FF
+; X64-NEXT: andl $33791, %eax # imm = 0x83FF
; X64-NEXT: orl $14336, %eax # imm = 0x3800
; X64-NEXT: addl $-31744, %edx # imm = 0x8400
; X64-NEXT: movzwl %dx, %edx
diff --git a/llvm/test/CodeGen/X86/masked_load.ll b/llvm/test/CodeGen/X86/masked_load.ll
index d755c8e34e60b..88b51499518be 100644
--- a/llvm/test/CodeGen/X86/masked_load.ll
+++ b/llvm/test/CodeGen/X86/masked_load.ll
@@ -701,15 +701,15 @@ define <8 x double> @load_v8f64_i8(i8 %trigger, ptr %addr, <8 x double> %dst) {
; AVX1-LABEL: load_v8f64_i8:
; AVX1: ## %bb.0:
; AVX1-NEXT: movl %edi, %eax
-; AVX1-NEXT: shrb %al
+; AVX1-NEXT: shrb $2, %al
; AVX1-NEXT: andb $1, %al
; AVX1-NEXT: movl %edi, %ecx
+; AVX1-NEXT: shrb %cl
; AVX1-NEXT: andb $1, %cl
-; AVX1-NEXT: vmovd %ecx, %xmm2
-; AVX1-NEXT: vpinsrb $2, %eax, %xmm2, %xmm2
-; AVX1-NEXT: movl %edi, %eax
-; AVX1-NEXT: shrb $2, %al
-; AVX1-NEXT: andb $1, %al
+; AVX1-NEXT: movl %edi, %edx
+; AVX1-NEXT: andl $1, %edx
+; AVX1-NEXT: vmovd %edx, %xmm2
+; AVX1-NEXT: vpinsrb $2, %ecx, %xmm2, %xmm2
; AVX1-NEXT: vpinsrb $4, %eax, %xmm2, %xmm2
; AVX1-NEXT: movl %edi, %eax
; AVX1-NEXT: shrb $3, %al
@@ -750,15 +750,15 @@ define <8 x double> @load_v8f64_i8(i8 %trigger, ptr %addr, <8 x double> %dst) {
; AVX2-LABEL: load_v8f64_i8:
; AVX2: ## %bb.0:
; AVX2-NEXT: movl %edi, %eax
-; AVX2-NEXT: shrb %al
+; AVX2-NEXT: shrb $2, %al
; AVX2-NEXT: andb $1, %al
; AVX2-NEXT: movl %edi, %ecx
+; AVX2-NEXT: shrb %cl
; AVX2-NEXT: andb $1, %cl
-; AVX2-NEXT: vmovd %ecx, %xmm2
-; AVX2-NEXT: vpinsrb $2, %eax, %xmm2, %xmm2
-; AVX2-NEXT: movl %edi, %eax
-; AVX2-NEXT: shrb $2, %al
-; AVX2-NEXT: andb $1, %al
+; AVX2-NEXT: movl %edi, %edx
+; AVX2-NEXT: andl $1, %edx
+; AVX2-NEXT: vmovd %edx, %xmm2
+; AVX2-NEXT: vpinsrb $2, %ecx, %xmm2, %xmm2
; AVX2-NEXT: vpinsrb $4, %eax, %xmm2, %xmm2
; AVX2-NEXT: movl %edi, %eax
; AVX2-NEXT: shrb $3, %al
@@ -1205,7 +1205,7 @@ define <2 x float> @load_v2f32_i2(i2 %trigger, ptr %addr, <2 x float> %dst) {
; AVX1OR2-NEXT: movl %edi, %eax
; AVX1OR2-NEXT: andb $2, %al
; AVX1OR2-NEXT: shrb %al
-; AVX1OR2-NEXT: andb $1, %dil
+; AVX1OR2-NEXT: andl $1, %edi
; AVX1OR2-NEXT: vmovd %edi, %xmm1
; AVX1OR2-NEXT: vpinsrb $8, %eax, %xmm1, %xmm1
; AVX1OR2-NEXT: vinsertps {{.*#+}} xmm1 = xmm1[0,2],zero,zero
diff --git a/llvm/test/CodeGen/X86/masked_store.ll b/llvm/test/CodeGen/X86/masked_store.ll
index 5882f3924473e..c0897c290bc05 100644
--- a/llvm/test/CodeGen/X86/masked_store.ll
+++ b/llvm/test/CodeGen/X86/masked_store.ll
@@ -466,7 +466,7 @@ define void @store_v2f32_i2(i2 %trigger, ptr %addr, <2 x float> %val) nounwind {
; AVX1OR2-NEXT: movl %edi, %eax
; AVX1OR2-NEXT: andb $2, %al
; AVX1OR2-NEXT: shrb %al
-; AVX1OR2-NEXT: andb $1, %dil
+; AVX1OR2-NEXT: andl $1, %edi
; AVX1OR2-NEXT: vmovd %edi, %xmm1
; AVX1OR2-NEXT: vpinsrb $8, %eax, %xmm1, %xmm1
; AVX1OR2-NEXT: vinsertps {{.*#+}} xmm1 = xmm1[0,2],zero,zero
diff --git a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-innerouter.ll b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-innerouter.ll
index 9a8719f9a64fa..7b53f2b22b08c 100644
--- a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-innerouter.ll
+++ b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-innerouter.ll
@@ -39,7 +39,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-NOBMI-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-NOBMI-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-NOBMI-NEXT: andl $4080, %edi # imm = 0xFF0
-; CHECK-NOBMI-NEXT: andl $-4081, %esi # imm = 0xF00F
+; CHECK-NOBMI-NEXT: andl $61455, %esi # imm = 0xF00F
; CHECK-NOBMI-NEXT: leal (%rsi,%rdi), %eax
; CHECK-NOBMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NOBMI-NEXT: retq
@@ -49,7 +49,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-BMI-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-BMI-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-BMI-NEXT: andl $4080, %edi # imm = 0xFF0
-; CHECK-BMI-NEXT: andl $-4081, %esi # imm = 0xF00F
+; CHECK-BMI-NEXT: andl $61455, %esi # imm = 0xF00F
; CHECK-BMI-NEXT: leal (%rsi,%rdi), %eax
; CHECK-BMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-BMI-NEXT: retq
diff --git a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbits.ll b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbits.ll
index c4c4e5ed1fdde..c58f110fe9e64 100644
--- a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbits.ll
+++ b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbits.ll
@@ -39,7 +39,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-NOBMI-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-NOBMI-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-NOBMI-NEXT: andl $21845, %edi # imm = 0x5555
-; CHECK-NOBMI-NEXT: andl $-21846, %esi # imm = 0xAAAA
+; CHECK-NOBMI-NEXT: andl $43690, %esi # imm = 0xAAAA
; CHECK-NOBMI-NEXT: leal (%rsi,%rdi), %eax
; CHECK-NOBMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NOBMI-NEXT: retq
@@ -49,7 +49,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-BMI-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-BMI-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-BMI-NEXT: andl $21845, %edi # imm = 0x5555
-; CHECK-BMI-NEXT: andl $-21846, %esi # imm = 0xAAAA
+; CHECK-BMI-NEXT: andl $43690, %esi # imm = 0xAAAA
; CHECK-BMI-NEXT: leal (%rsi,%rdi), %eax
; CHECK-BMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-BMI-NEXT: retq
diff --git a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbytehalves.ll b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbytehalves.ll
index 2ea74f3942387..f5dbc51fe518f 100644
--- a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbytehalves.ll
+++ b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-interleavedbytehalves.ll
@@ -39,7 +39,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-NOBMI-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-NOBMI-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-NOBMI-NEXT: andl $3855, %edi # imm = 0xF0F
-; CHECK-NOBMI-NEXT: andl $-3856, %esi # imm = 0xF0F0
+; CHECK-NOBMI-NEXT: andl $61680, %esi # imm = 0xF0F0
; CHECK-NOBMI-NEXT: leal (%rsi,%rdi), %eax
; CHECK-NOBMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NOBMI-NEXT: retq
@@ -49,7 +49,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-BMI-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-BMI-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-BMI-NEXT: andl $3855, %edi # imm = 0xF0F
-; CHECK-BMI-NEXT: andl $-3856, %esi # imm = 0xF0F0
+; CHECK-BMI-NEXT: andl $61680, %esi # imm = 0xF0F0
; CHECK-BMI-NEXT: leal (%rsi,%rdi), %eax
; CHECK-BMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-BMI-NEXT: retq
diff --git a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-lowhigh.ll b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-lowhigh.ll
index eb6accd3e623b..9b85a21dd23bc 100644
--- a/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-lowhigh.ll
+++ b/llvm/test/CodeGen/X86/unfold-masked-merge-scalar-constmask-lowhigh.ll
@@ -37,7 +37,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-NOBMI-LABEL: out16_constmask:
; CHECK-NOBMI: # %bb.0:
; CHECK-NOBMI-NEXT: movzbl %dil, %eax
-; CHECK-NOBMI-NEXT: andl $-256, %esi
+; CHECK-NOBMI-NEXT: andl $65280, %esi # imm = 0xFF00
; CHECK-NOBMI-NEXT: orl %esi, %eax
; CHECK-NOBMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NOBMI-NEXT: retq
@@ -45,7 +45,7 @@ define i16 @out16_constmask(i16 %x, i16 %y) {
; CHECK-BMI-LABEL: out16_constmask:
; CHECK-BMI: # %bb.0:
; CHECK-BMI-NEXT: movzbl %dil, %eax
-; CHECK-BMI-NEXT: andl $-256, %esi
+; CHECK-BMI-NEXT: andl $65280, %esi # imm = 0xFF00
; CHECK-BMI-NEXT: orl %esi, %eax
; CHECK-BMI-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-BMI-NEXT: retq
More information about the llvm-commits
mailing list