[all-commits] [llvm/llvm-project] 0952cf: [InstCombine] decomposeSimpleLinearExpr should bai...

Wael Yehia via All-commits all-commits at lists.llvm.org
Tue Jun 7 17:58:20 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0952cf5bbbc4bc5470443b53e07c88fb0013b42a
      https://github.com/llvm/llvm-project/commit/0952cf5bbbc4bc5470443b53e07c88fb0013b42a
  Author: Wael Yehia <wyehia at ca.ibm.com>
  Date:   2022-06-08 (Wed, 08 Jun 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
    A llvm/test/Transforms/InstCombine/neg-alloca.ll

  Log Message:
  -----------
  [InstCombine] decomposeSimpleLinearExpr should bail out on negative operands.

InstCombine tries to rewrite

  %prod = mul nsw i64 %X,   Scale
  %acc = add nsw i64 %prod,   Offset
  %0 = alloca i8, i64 %acc, align 4
  %1 = bitcast i8* %0 to i32*
  Use ( %1 )

into

  %prod = mul nsw i64 %X,   Scale/4
  %acc = add nsw i64 %prod,   Offset/4
  %0 = alloca i32, i64 %acc, align 4
  Use (%0)

But it assumes Scale is unsigned, and performs an unsigned division.
So we should bail out if Scale cannot be interpreted as an unsigned safely.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D126546




More information about the All-commits mailing list