[all-commits] [llvm/llvm-project] bf8dae: [InstCombine] Narrow llvm.abs through trunc. (#199...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed May 27 07:50:31 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bf8dae18aa318aac5558a38ce34c696c569feacf
      https://github.com/llvm/llvm-project/commit/bf8dae18aa318aac5558a38ce34c696c569feacf
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    A llvm/test/Transforms/InstCombine/trunc-abs-intrinsics.ll

  Log Message:
  -----------
  [InstCombine] Narrow llvm.abs through trunc. (#199643)

Update EvaluateInDifferentType / canEvaluateTruncated to narrow abs
intrinsics when the operand has at least OrigBitWidth - BitWidth + 1
sign bits. The transform always emits the narrow abs with
IsIntMinPoison=false, as the narrowed value may be INT_MIN in the narrow
type, while not in the original width.

Alive2 Proof with weaker precondition (top and truncated sign bits must
match): https://alive2.llvm.org/ce/z/AMQRmi

End-to-end C pixel math example: https://clang.godbolt.org/z/Ma8bsTGTY

PR: https://github.com/llvm/llvm-project/pull/199643



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