[PATCH] D48041: [SCEV] Add transform zext((A * B * ...)<nuw>) --> (zext(A) * zext(B) * ...)<nuw>.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 11 19:39:39 PDT 2018
Hi Justin,
This (or the previous) commit caused a ~1.4% compile time slowdown on CTMark/mafft/pairlocalalign. Any ideas on how we can avoid it?
I don’t have more details at the moment, but I’d be happy to dig deeper if that helps.
Thanks,
Michael
> On Jun 11, 2018, at 12:02 PM, Justin Lebar via Phabricator via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL334429: [SCEV] Add transform zext((A * B * ...)<nuw>) --> (zext(A) * zext(B) * ... (authored by jlebar, committed by ).
>
> Changed prior to commit:
> https://reviews.llvm.org/D48041?vs=150799&id=150807#toc
>
> Repository:
> rL LLVM
>
> https://reviews.llvm.org/D48041
>
> Files:
> llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll
>
>
> Index: llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll
> ===================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll
> +++ llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll
> @@ -0,0 +1,31 @@
> +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
> +
> +; Check that we convert
> +; zext((a * b)<nuw>)
> +; to
> +; (zext(a) * zext(b))<nuw>
> +
> +declare i32 @get_int();
> +
> +; Transform doesn't apply here, because %a lacks range metadata.
> +; CHECK-LABEL: @no_range
> +define void @no_range() {
> + %a = call i32 @get_int()
> + %b = mul i32 %a, 4
> + %c = zext i32 %b to i64
> + ; CHECK: %c
> + ; CHECK-NEXT: --> (zext i32 (4 * %a) to i64)
> + ret void
> +}
> +
> +; CHECK-LABEL: @range
> +define void @range() {
> + %a = call i32 @get_int(), !range !0
> + %b = mul i32 %a, 4
> + %c = zext i32 %b to i64
> + ; CHECK: %c
> + ; CHECK-NEXT: --> (4 * (zext i32 %a to i64))<nuw>
> + ret void
> +}
> +
> +!0 = !{i32 0, i32 100}
> Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> ===================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> @@ -1778,6 +1778,18 @@
> }
> }
>
> + if (auto *SA = dyn_cast<SCEVMulExpr>(Op)) {
> + // zext((A * B * ...)<nuw>) --> (zext(A) * zext(B) * ...)<nuw>
> + if (SA->hasNoUnsignedWrap()) {
> + // If the multiply does not unsign overflow then we can, by definition,
> + // commute the zero extension with the multiply operation.
> + SmallVector<const SCEV *, 4> Ops;
> + for (const auto *Op : SA->operands())
> + Ops.push_back(getZeroExtendExpr(Op, Ty, Depth + 1));
> + return getMulExpr(Ops, SCEV::FlagNUW, Depth + 1);
> + }
> + }
> +
> // The cast wasn't folded; create an explicit cast node.
> // Recompute the insert position, as it may have been invalidated.
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
>
>
> <D48041.150807.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list