[all-commits] [llvm/llvm-project] 8017ca: Reapply "[AArch64] Combine and and lsl into ubfiz"...

Cullen Rhodes via All-commits all-commits at lists.llvm.org
Tue Jan 28 03:27:56 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8017ca1d0056907331ff7542ac9ff1ff5ec969a2
      https://github.com/llvm/llvm-project/commit/8017ca1d0056907331ff7542ac9ff1ff5ec969a2
  Author: Cullen Rhodes <cullen.rhodes at arm.com>
  Date:   2025-01-28 (Tue, 28 Jan 2025)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/test/CodeGen/AArch64/const-shift-of-constmasked.ll
    M llvm/test/CodeGen/AArch64/extract-bits.ll
    M llvm/test/CodeGen/AArch64/fpenv.ll
    M llvm/test/CodeGen/AArch64/xbfiz.ll

  Log Message:
  -----------
  Reapply "[AArch64] Combine and and lsl into ubfiz" (#123356) (#124576)

Patch was reverted due to test case (added) exposing an infinite loop in
combiner, where (shl C1, C2) create by performSHLCombine isn't
constant-folded:

  Combining: t14: i64 = shl t12, Constant:i64<1>
Creating new node: t36: i64 = shl
OpaqueConstant:i64<-2401053089408754003>, Constant:i64<1>
  Creating new node: t37: i64 = shl t6, Constant:i64<1>
  Creating new node: t38: i64 = and t37, t36
   ... into: t38: i64 = and t37, t36
  ...
  Combining: t38: i64 = and t37, t36
Creating new node: t39: i64 = and t6,
OpaqueConstant:i64<-2401053089408754003>
  Creating new node: t40: i64 = shl t39, Constant:i64<1>
   ... into: t40: i64 = shl t39, Constant:i64<1>

and subsequently gets simplified by DAGCombiner::visitAND:

  // Simplify: (and (op x...), (op y...))  -> (op (and x, y))
  if (N0.getOpcode() == N1.getOpcode())
    if (SDValue V = hoistLogicOpWithSameOpcodeHands(N))
      return V;

before being folded by performSHLCombine once again and so on.

The combine in performSHLCombine should only be done if (shl C1, C2) can
be constant-folded, it may otherwise be unsafe and generally have a
worse end result. Thanks to Dave Sherwood for his insight on this one.

This reverts commit f719771f251d7c30eca448133fe85730f19a6bd1.



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