<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Yeah, I will work on getting some today.</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p style="margin-top: 0px; margin-bottom: 0px;"></p>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Sam Parker</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Compilation Tools Engineer | Arm</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">. . . . . . . . . . . . . . . . . . . . . . . . . . .</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Arm.com</span></p>
<p style="margin-top: 0px; margin-bottom: 0px;"></p>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Roman Lebedev <lebedev.ri@gmail.com><br>
<b>Sent:</b> 15 June 2020 07:56<br>
<b>To:</b> Sam Parker <Sam.Parker@arm.com>; Sam Parker <llvmlistbot@llvm.org><br>
<b>Cc:</b> cfe-commits@lists.llvm.org <cfe-commits@lists.llvm.org><br>
<b>Subject:</b> Re: [clang] 3e39760 - Revert "Return "[InstCombine] Simplify compare of Phi with constant inputs against a constant""</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Reproducers?<br>
<br>
On Mon, Jun 15, 2020 at 9:47 AM Sam Parker via cfe-commits<br>
<cfe-commits@lists.llvm.org> wrote:<br>
><br>
><br>
> Author: Sam Parker<br>
> Date: 2020-06-15T07:46:28+01:00<br>
> New Revision: 3e39760f8eaad4770efa05824768e67237915cf5<br>
><br>
> URL: <a href="https://github.com/llvm/llvm-project/commit/3e39760f8eaad4770efa05824768e67237915cf5">
https://github.com/llvm/llvm-project/commit/3e39760f8eaad4770efa05824768e67237915cf5</a><br>
> DIFF: <a href="https://github.com/llvm/llvm-project/commit/3e39760f8eaad4770efa05824768e67237915cf5.diff">
https://github.com/llvm/llvm-project/commit/3e39760f8eaad4770efa05824768e67237915cf5.diff</a><br>
><br>
> LOG: Revert "Return "[InstCombine] Simplify compare of Phi with constant inputs against a constant""<br>
><br>
> This reverts commit 23291b9863c8af7ad348c4a7d85d8d784df88eb1.<br>
><br>
> This caused performance regressions.<br>
><br>
> Added:<br>
><br>
><br>
> Modified:<br>
> clang/test/CodeGenObjC/exceptions.m<br>
> llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp<br>
> llvm/test/Transforms/InstCombine/icmp-constant-phi.ll<br>
> llvm/test/Transforms/InstCombine/indexed-gep-compares.ll<br>
> llvm/test/Transforms/InstCombine/zext-or-icmp.ll<br>
><br>
> Removed:<br>
><br>
><br>
><br>
> ################################################################################<br>
> diff --git a/clang/test/CodeGenObjC/exceptions.m b/clang/test/CodeGenObjC/exceptions.m<br>
> index 3bb4f86cf025..741f8a819158 100644<br>
> --- a/clang/test/CodeGenObjC/exceptions.m<br>
> +++ b/clang/test/CodeGenObjC/exceptions.m<br>
> @@ -97,7 +97,7 @@ void f3() {<br>
> // CHECK: call void @objc_exception_try_exit(<br>
> f3_helper(0, &x);<br>
> } @finally {<br>
> - // CHECK: [[DEST1:%.*]] = phi i1 [ true, {{%.*}} ], [ false, {{%.*}} ]<br>
> + // CHECK: [[DEST1:%.*]] = phi i32 [ 0, {{%.*}} ], [ 3, {{%.*}} ]<br>
> // CHECK: call void @objc_exception_try_enter<br>
> // CHECK: call i32 @_setjmp<br>
> @try {<br>
> @@ -105,7 +105,7 @@ void f3() {<br>
> // CHECK: call void @objc_exception_try_exit(<br>
> f3_helper(1, &x);<br>
> } @finally {<br>
> - // CHECK: [[DEST2:%.*]] = phi i1 [ true, {{%.*}} ], [ false, {{%.*}} ]<br>
> + // CHECK: [[DEST2:%.*]] = phi i32 [ 0, {{%.*}} ], [ 5, {{%.*}} ]<br>
> // CHECK: call void @f3_helper(i32 2, i32* nonnull [[X]])<br>
> f3_helper(2, &x);<br>
><br>
><br>
> diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp<br>
> index a7b9ecb9bf3b..48375a1a323f 100644<br>
> --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp<br>
> +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp<br>
> @@ -1452,27 +1452,6 @@ Instruction *InstCombiner::foldICmpWithConstant(ICmpInst &Cmp) {<br>
> if (Instruction *Res = processUGT_ADDCST_ADD(Cmp, A, B, CI2, CI, *this))<br>
> return Res;<br>
><br>
> - // icmp(phi(C1, C2, ...), C) -> phi(icmp(C1, C), icmp(C2, C), ...).<br>
> - Constant *C = dyn_cast<Constant>(Op1);<br>
> - if (!C)<br>
> - return nullptr;<br>
> -<br>
> - if (auto *Phi = dyn_cast<PHINode>(Op0))<br>
> - if (all_of(Phi->operands(), [](Value *V) { return isa<Constant>(V); })) {<br>
> - Type *Ty = Cmp.getType();<br>
> - Builder.SetInsertPoint(Phi);<br>
> - PHINode *NewPhi =<br>
> - Builder.CreatePHI(Ty, Phi->getNumOperands());<br>
> - for (BasicBlock *Predecessor : predecessors(Phi->getParent())) {<br>
> - auto *Input =<br>
> - cast<Constant>(Phi->getIncomingValueForBlock(Predecessor));<br>
> - auto *BoolInput = ConstantExpr::getCompare(Pred, Input, C);<br>
> - NewPhi->addIncoming(BoolInput, Predecessor);<br>
> - }<br>
> - NewPhi->takeName(&Cmp);<br>
> - return replaceInstUsesWith(Cmp, NewPhi);<br>
> - }<br>
> -<br>
> return nullptr;<br>
> }<br>
><br>
><br>
> diff --git a/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll b/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll<br>
> index 7d4b9294143f..9753149f8012 100644<br>
> --- a/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll<br>
> +++ b/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll<br>
> @@ -2,6 +2,8 @@<br>
> ; RUN: opt < %s -instcombine -S | FileCheck %s<br>
> ; RUN: opt < %s -passes=instcombine -S | FileCheck %s<br>
><br>
> +; TODO: Replace with boolean Phi.<br>
> +<br>
> define i1 @test_eq(i1 %cond) {<br>
> ; CHECK-LABEL: @test_eq(<br>
> ; CHECK-NEXT: entry:<br>
> @@ -11,9 +13,10 @@ define i1 @test_eq(i1 %cond) {<br>
> ; CHECK: if.false:<br>
> ; CHECK-NEXT: br label [[MERGE]]<br>
> ; CHECK: merge:<br>
> -; CHECK-NEXT: [[COMPARE:%.*]] = phi i1 [ true, [[IF_FALSE]] ], [ false, [[IF_TRUE]] ]<br>
> +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, [[IF_FALSE]] ]<br>
> ; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> ; CHECK: exit:<br>
> +; CHECK-NEXT: [[COMPARE:%.*]] = icmp eq i32 [[PHI]], 456<br>
> ; CHECK-NEXT: ret i1 [[COMPARE]]<br>
> ;<br>
> entry:<br>
> @@ -43,9 +46,10 @@ define i1 @test_slt(i1 %cond) {<br>
> ; CHECK: if.false:<br>
> ; CHECK-NEXT: br label [[MERGE]]<br>
> ; CHECK: merge:<br>
> -; CHECK-NEXT: [[COMPARE:%.*]] = phi i1 [ false, [[IF_FALSE]] ], [ true, [[IF_TRUE]] ]<br>
> +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, [[IF_FALSE]] ]<br>
> ; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> ; CHECK: exit:<br>
> +; CHECK-NEXT: [[COMPARE:%.*]] = icmp ult i32 [[PHI]], 456<br>
> ; CHECK-NEXT: ret i1 [[COMPARE]]<br>
> ;<br>
> entry:<br>
> @@ -106,9 +110,10 @@ define i1 @test_ne(i1 %cond) {<br>
> ; CHECK: if.false:<br>
> ; CHECK-NEXT: br label [[MERGE]]<br>
> ; CHECK: merge:<br>
> -; CHECK-NEXT: [[COMPARE:%.*]] = phi i1 [ false, [[IF_FALSE]] ], [ true, [[IF_TRUE]] ]<br>
> +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, [[IF_FALSE]] ]<br>
> ; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> ; CHECK: exit:<br>
> +; CHECK-NEXT: [[COMPARE:%.*]] = icmp ne i32 [[PHI]], 456<br>
> ; CHECK-NEXT: ret i1 [[COMPARE]]<br>
> ;<br>
> entry:<br>
> @@ -128,164 +133,3 @@ exit:<br>
> %compare = icmp ne i32 %phi, 456<br>
> ret i1 %compare<br>
> }<br>
> -<br>
> -define i1 @test_ne_undef(i1 %cond) {<br>
> -; CHECK-LABEL: @test_ne_undef(<br>
> -; CHECK-NEXT: entry:<br>
> -; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]<br>
> -; CHECK: if.true:<br>
> -; CHECK-NEXT: br label [[MERGE:%.*]]<br>
> -; CHECK: if.false:<br>
> -; CHECK-NEXT: br label [[MERGE]]<br>
> -; CHECK: merge:<br>
> -; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> -; CHECK: exit:<br>
> -; CHECK-NEXT: ret i1 false<br>
> -;<br>
> -entry:<br>
> - br i1 %cond, label %if.true, label %if.false<br>
> -<br>
> -if.true:<br>
> - br label %merge<br>
> -<br>
> -if.false:<br>
> - br label %merge<br>
> -<br>
> -merge:<br>
> - %phi = phi i32 [undef, %if.true], [456, %if.false]<br>
> - br label %exit<br>
> -<br>
> -exit:<br>
> - %compare = icmp ne i32 %phi, 456<br>
> - ret i1 %compare<br>
> -}<br>
> -<br>
> -define <2 x i1> @test_ne_int_vector(i1 %cond) {<br>
> -; CHECK-LABEL: @test_ne_int_vector(<br>
> -; CHECK-NEXT: entry:<br>
> -; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]<br>
> -; CHECK: if.true:<br>
> -; CHECK-NEXT: br label [[MERGE:%.*]]<br>
> -; CHECK: if.false:<br>
> -; CHECK-NEXT: br label [[MERGE]]<br>
> -; CHECK: merge:<br>
> -; CHECK-NEXT: [[COMPARE:%.*]] = phi <2 x i1> [ <i1 true, i1 false>, [[IF_FALSE]] ], [ <i1 false, i1 true>, [[IF_TRUE]] ]<br>
> -; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> -; CHECK: exit:<br>
> -; CHECK-NEXT: ret <2 x i1> [[COMPARE]]<br>
> -;<br>
> -entry:<br>
> - br i1 %cond, label %if.true, label %if.false<br>
> -<br>
> -if.true:<br>
> - br label %merge<br>
> -<br>
> -if.false:<br>
> - br label %merge<br>
> -<br>
> -merge:<br>
> - %phi = phi <2 x i32> [<i32 123, i32 123>, %if.true], [<i32 456, i32 456>, %if.false]<br>
> - br label %exit<br>
> -<br>
> -exit:<br>
> - %compare = icmp ne <2 x i32> %phi, <i32 123, i32 456><br>
> - ret <2 x i1> %compare<br>
> -}<br>
> -<br>
> -; TODO: We can also constant-fold this comparison for floats.<br>
> -define i1 @test_ne_float(i1 %cond) {<br>
> -; CHECK-LABEL: @test_ne_float(<br>
> -; CHECK-NEXT: entry:<br>
> -; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]<br>
> -; CHECK: if.true:<br>
> -; CHECK-NEXT: br label [[MERGE:%.*]]<br>
> -; CHECK: if.false:<br>
> -; CHECK-NEXT: br label [[MERGE]]<br>
> -; CHECK: merge:<br>
> -; CHECK-NEXT: [[PHI:%.*]] = phi float [ 1.000000e+00, [[IF_TRUE]] ], [ 1.250000e+00, [[IF_FALSE]] ]<br>
> -; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> -; CHECK: exit:<br>
> -; CHECK-NEXT: [[COMPARE:%.*]] = fcmp one float [[PHI]], 1.250000e+00<br>
> -; CHECK-NEXT: ret i1 [[COMPARE]]<br>
> -;<br>
> -entry:<br>
> - br i1 %cond, label %if.true, label %if.false<br>
> -<br>
> -if.true:<br>
> - br label %merge<br>
> -<br>
> -if.false:<br>
> - br label %merge<br>
> -<br>
> -merge:<br>
> - %phi = phi float [1.0, %if.true], [1.25, %if.false]<br>
> - br label %exit<br>
> -<br>
> -exit:<br>
> - %compare = fcmp one float %phi, 1.25<br>
> - ret i1 %compare<br>
> -}<br>
> -<br>
> -define i1 @test_ne_float_undef(i1 %cond) {<br>
> -; CHECK-LABEL: @test_ne_float_undef(<br>
> -; CHECK-NEXT: entry:<br>
> -; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]<br>
> -; CHECK: if.true:<br>
> -; CHECK-NEXT: br label [[MERGE:%.*]]<br>
> -; CHECK: if.false:<br>
> -; CHECK-NEXT: br label [[MERGE]]<br>
> -; CHECK: merge:<br>
> -; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> -; CHECK: exit:<br>
> -; CHECK-NEXT: ret i1 true<br>
> -;<br>
> -entry:<br>
> - br i1 %cond, label %if.true, label %if.false<br>
> -<br>
> -if.true:<br>
> - br label %merge<br>
> -<br>
> -if.false:<br>
> - br label %merge<br>
> -<br>
> -merge:<br>
> - %phi = phi float [1.0, %if.true], [undef, %if.false]<br>
> - br label %exit<br>
> -<br>
> -exit:<br>
> - %compare = fcmp one float %phi, 1.25<br>
> - ret i1 %compare<br>
> -}<br>
> -<br>
> -define <2 x i1> @test_ne_float_vector(i1 %cond) {<br>
> -; CHECK-LABEL: @test_ne_float_vector(<br>
> -; CHECK-NEXT: entry:<br>
> -; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]<br>
> -; CHECK: if.true:<br>
> -; CHECK-NEXT: br label [[MERGE:%.*]]<br>
> -; CHECK: if.false:<br>
> -; CHECK-NEXT: br label [[MERGE]]<br>
> -; CHECK: merge:<br>
> -; CHECK-NEXT: [[PHI:%.*]] = phi <2 x float> [ <float 1.232500e+02, float 1.232500e+02>, [[IF_TRUE]] ], [ <float 4.562500e+02, float 4.562500e+02>, [[IF_FALSE]] ]<br>
> -; CHECK-NEXT: br label [[EXIT:%.*]]<br>
> -; CHECK: exit:<br>
> -; CHECK-NEXT: [[COMPARE:%.*]] = fcmp one <2 x float> [[PHI]], <float 1.232500e+02, float 4.562500e+02><br>
> -; CHECK-NEXT: ret <2 x i1> [[COMPARE]]<br>
> -;<br>
> -entry:<br>
> - br i1 %cond, label %if.true, label %if.false<br>
> -<br>
> -if.true:<br>
> - br label %merge<br>
> -<br>
> -if.false:<br>
> - br label %merge<br>
> -<br>
> -merge:<br>
> - %phi = phi <2 x float> [<float 123.25, float 123.25>, %if.true], [<float 456.25, float 456.25>, %if.false]<br>
> - br label %exit<br>
> -<br>
> -exit:<br>
> - %compare = fcmp one <2 x float> %phi, <float 123.25, float 456.25><br>
> - ret <2 x i1> %compare<br>
> -}<br>
><br>
> diff --git a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll<br>
> index 859fd6437bb3..71afed438d10 100644<br>
> --- a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll<br>
> +++ b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll<br>
> @@ -182,7 +182,8 @@ bb10:<br>
> ret i1 %cmp<br>
> }<br>
> ; CHECK-LABEL: @test7(<br>
> -; CHECK: %[[cmp:.*]] = phi i1 [ true, %bb7 ], [ false, %entry ]<br>
> +; CHECK: %[[phi:.*]] = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]<br>
> +; CHECK: %[[cmp:.*]] = icmp eq i64* %[[phi]], getelementptr inbounds (i64, i64* @pr30402, i32 1)<br>
> ; CHECK: ret i1 %[[cmp]]<br>
><br>
><br>
><br>
> diff --git a/llvm/test/Transforms/InstCombine/zext-or-icmp.ll b/llvm/test/Transforms/InstCombine/zext-or-icmp.ll<br>
> index 973c5a53abac..6c65032cebe9 100644<br>
> --- a/llvm/test/Transforms/InstCombine/zext-or-icmp.ll<br>
> +++ b/llvm/test/Transforms/InstCombine/zext-or-icmp.ll<br>
> @@ -40,8 +40,8 @@ block2:<br>
> ret i32 %conv2<br>
><br>
> ; CHECK-LABEL: dont_widen_undef(<br>
> -; CHECK: %cmp.i = phi i1 [ false, %block1 ], [ true, %entry ]<br>
> -; CHECK-NEXT: %m.011 = phi i32 [ 0, %block1 ], [ 33, %entry ]<br>
> +; CHECK: %m.011 = phi i32 [ 33, %entry ], [ 0, %block1 ]<br>
> +; CHECK-NEXT: %cmp.i = icmp ugt i32 %m.011, 1<br>
> ; CHECK-NEXT: %m.1.op = lshr i32 1, %m.011<br>
> ; CHECK-NEXT: %sext.mask = and i32 %m.1.op, 65535<br>
> ; CHECK-NEXT: %cmp115 = icmp ne i32 %sext.mask, 0<br>
><br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> cfe-commits@lists.llvm.org<br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div>
</span></font></div>
</body>
</html>