[all-commits] [llvm/llvm-project] 5c2565: [InstCombine] Fix assertion in GEP exact div/shr i...

lijinpei-amd via All-commits all-commits at lists.llvm.org
Thu Jun 4 03:25:13 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5c2565b67d086a3f56ce837424402084c37c7895
      https://github.com/llvm/llvm-project/commit/5c2565b67d086a3f56ce837424402084c37c7895
  Author: lijinpei-amd <jinpli at amd.com>
  Date:   2026-06-04 (Thu, 04 Jun 2026)

  Changed paths:
    M llvm/include/llvm/IR/IRBuilder.h
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    A llvm/test/Transforms/InstCombine/gep-canonicalize-index-constfold.ll

  Log Message:
  -----------
  [InstCombine] Fix assertion in GEP exact div/shr index canonicalization (#201431)

When canonicalizing the index of `(gep ptr, (div/shr exact X, C))`,
visitGetElementPtrInst builds the new index with Builder.CreateBinOp and
then sets the exact flag via
`cast<BinaryOperator>(NewOp)->setIsExact()`. If X is a constant (as can
be proved during InstCombine), the folding builder constant-folds NewOp
to a non-BinaryOperator, so the cast asserts.

Fix this by adding a CreateExactBinOp API, so the exact flag is set on creation.

Fixes #190324.



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