Skip to content

Commit 0fac9da

Browse files
committed
[DAG] getNode() - relax (zext (trunc x)) -> x fold iff the upper bits are known zero.
Just leave the (zext (trunc (and x, c))) pattern which is still being used to create some zext_inreg patterns.
1 parent 621183c commit 0fac9da

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5718,12 +5718,12 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
57185718

57195719
// Skip unnecessary zext_inreg pattern:
57205720
// (zext (trunc x)) -> x iff the upper bits are known zero.
5721-
// TODO: Generalize to just the MaskedValueIsZero check?
5721+
// TODO: Remove (zext (trunc (and x, c))) exception which some targets
5722+
// use to recognise zext_inreg patterns.
57225723
if (OpOpcode == ISD::TRUNCATE) {
57235724
SDValue OpOp = N1.getOperand(0);
57245725
if (OpOp.getValueType() == VT) {
5725-
if (OpOp.getOpcode() == ISD::AssertZext ||
5726-
OpOp.getOpcode() == ISD::SRL) {
5726+
if (OpOp.getOpcode() != ISD::AND) {
57275727
APInt HiBits = APInt::getBitsSetFrom(VT.getScalarSizeInBits(),
57285728
N1.getScalarValueSizeInBits());
57295729
if (MaskedValueIsZero(OpOp, HiBits)) {

llvm/test/CodeGen/X86/addr-mode-matcher-4.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ define double @zext_shl_mul(ptr %a0, ptr %a1) {
1919
; X64: # %bb.0:
2020
; X64-NEXT: movzwl (%rsi), %eax
2121
; X64-NEXT: leaq (%rax,%rax,4), %rax
22-
; X64-NEXT: movl %eax, %eax
2322
; X64-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
2423
; X64-NEXT: retq
2524
%ld = load i16, ptr %a1, align 2

0 commit comments

Comments
 (0)