[llvm] d3e3f36 - Revert "[ScalarEvolution] createSCEV(): recognize `udiv`/`urem` disguised as an `sdiv`/`srem`"

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 07:47:54 PDT 2020


Hm, on which bots was that failing?

On Mon, Jul 6, 2020 at 5:42 PM Kadir Cetinkaya via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Mikhail Goncharov
> Date: 2020-07-06T16:41:59+02:00
> New Revision: d3e3f36ff1151f565730977ac4f663a2ccee48ae
>
> URL: https://github.com/llvm/llvm-project/commit/d3e3f36ff1151f565730977ac4f663a2ccee48ae
> DIFF: https://github.com/llvm/llvm-project/commit/d3e3f36ff1151f565730977ac4f663a2ccee48ae.diff
>
> LOG: Revert "[ScalarEvolution] createSCEV(): recognize `udiv`/`urem` disguised as an `sdiv`/`srem`"
>
> Summary:
> This reverts commit 2c16100e6f72075564ea1f67fa5a82c269dafcd3.
>
> ninja check-polly fails:
>   Polly :: Isl/CodeGen/MemAccess/generate-all.ll
>   Polly :: ScopInfo/multidim_srem.ll
>
> Reviewers: kadircet, bollu
>
> Subscribers: hiraditya, llvm-commits
>
> Tags: #llvm
>
> Differential Revision: https://reviews.llvm.org/D83230
>
> Added:
>
>
> Modified:
>     llvm/lib/Analysis/ScalarEvolution.cpp
>     llvm/test/Analysis/ScalarEvolution/sdiv.ll
>     llvm/test/Analysis/ScalarEvolution/srem.ll
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
> index 75926aa3a960..609ad639d9c0 100644
> --- a/llvm/lib/Analysis/ScalarEvolution.cpp
> +++ b/llvm/lib/Analysis/ScalarEvolution.cpp
> @@ -6303,20 +6303,6 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
>        return getSCEV(U->getOperand(0));
>      break;
>
> -  case Instruction::SDiv:
> -    // If both operands are non-negative, this is just an udiv.
> -    if (isKnownNonNegative(getSCEV(U->getOperand(0))) &&
> -        isKnownNonNegative(getSCEV(U->getOperand(1))))
> -      return getUDivExpr(getSCEV(U->getOperand(0)), getSCEV(U->getOperand(1)));
> -    break;
> -
> -  case Instruction::SRem:
> -    // If both operands are non-negative, this is just an urem.
> -    if (isKnownNonNegative(getSCEV(U->getOperand(0))) &&
> -        isKnownNonNegative(getSCEV(U->getOperand(1))))
> -      return getURemExpr(getSCEV(U->getOperand(0)), getSCEV(U->getOperand(1)));
> -    break;
> -
>    // It's tempting to handle inttoptr and ptrtoint as no-ops, however this can
>    // lead to pointer expressions which cannot safely be expanded to GEPs,
>    // because ScalarEvolution doesn't respect the GEP aliasing rules when
>
> diff  --git a/llvm/test/Analysis/ScalarEvolution/sdiv.ll b/llvm/test/Analysis/ScalarEvolution/sdiv.ll
> index 106cda1b7f0f..b4895855ab71 100644
> --- a/llvm/test/Analysis/ScalarEvolution/sdiv.ll
> +++ b/llvm/test/Analysis/ScalarEvolution/sdiv.ll
> @@ -14,11 +14,11 @@ define dso_local void @_Z4loopi(i32 %width) local_unnamed_addr #0 {
>  ; CHECK-NEXT:    %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
>  ; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%for.cond> U: [0,-2147483648) S: [0,-2147483648) Exits: %width LoopDispositions: { %for.cond: Computable }
>  ; CHECK-NEXT:    %rem = sdiv i32 %i.0, 2
> -; CHECK-NEXT:    --> ({0,+,1}<nuw><nsw><%for.cond> /u 2) U: [0,1073741824) S: [0,1073741824) Exits: (%width /u 2) LoopDispositions: { %for.cond: Computable }
> +; CHECK-NEXT:    --> %rem U: full-set S: [-1073741824,1073741824) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %idxprom = sext i32 %rem to i64
> -; CHECK-NEXT:    --> ({0,+,1}<nuw><nsw><%for.cond> /u 2) U: [0,2147483648) S: [0,2147483648) Exits: ((zext i32 %width to i64) /u 2) LoopDispositions: { %for.cond: Computable }
> +; CHECK-NEXT:    --> (sext i32 %rem to i64) U: [-2147483648,2147483648) S: [-1073741824,1073741824) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %storage, i64 0, i64 %idxprom
> -; CHECK-NEXT:    --> ((4 * ({0,+,1}<nuw><nsw><%for.cond> /u 2))<nuw><nsw> + %storage)<nsw> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * ((zext i32 %width to i64) /u 2))<nuw><nsw> + %storage)<nsw> LoopDispositions: { %for.cond: Computable }
> +; CHECK-NEXT:    --> ((4 * (sext i32 %rem to i64))<nsw> + %storage)<nsw> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %1 = load i32, i32* %arrayidx, align 4
>  ; CHECK-NEXT:    --> %1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %call = call i32 @_Z3adji(i32 %1)
>
> diff  --git a/llvm/test/Analysis/ScalarEvolution/srem.ll b/llvm/test/Analysis/ScalarEvolution/srem.ll
> index 6debab34e3b3..365b40d88e24 100644
> --- a/llvm/test/Analysis/ScalarEvolution/srem.ll
> +++ b/llvm/test/Analysis/ScalarEvolution/srem.ll
> @@ -14,11 +14,11 @@ define dso_local void @_Z4loopi(i32 %width) local_unnamed_addr #0 {
>  ; CHECK-NEXT:    %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
>  ; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%for.cond> U: [0,-2147483648) S: [0,-2147483648) Exits: %width LoopDispositions: { %for.cond: Computable }
>  ; CHECK-NEXT:    %rem = srem i32 %i.0, 2
> -; CHECK-NEXT:    --> (zext i1 {false,+,true}<%for.cond> to i32) U: [0,2) S: [0,2) Exits: (zext i1 (trunc i32 %width to i1) to i32) LoopDispositions: { %for.cond: Computable }
> +; CHECK-NEXT:    --> %rem U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %idxprom = sext i32 %rem to i64
> -; CHECK-NEXT:    --> (zext i1 {false,+,true}<%for.cond> to i64) U: [0,2) S: [0,2) Exits: (zext i1 (trunc i32 %width to i1) to i64) LoopDispositions: { %for.cond: Computable }
> +; CHECK-NEXT:    --> (sext i32 %rem to i64) U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %storage, i64 0, i64 %idxprom
> -; CHECK-NEXT:    --> ((4 * (zext i1 {false,+,true}<%for.cond> to i64))<nuw><nsw> + %storage)<nsw> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * (zext i1 (trunc i32 %width to i1) to i64))<nuw><nsw> + %storage)<nsw> LoopDispositions: { %for.cond: Computable }
> +; CHECK-NEXT:    --> ((4 * (sext i32 %rem to i64))<nuw><nsw> + %storage)<nsw> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %1 = load i32, i32* %arrayidx, align 4
>  ; CHECK-NEXT:    --> %1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
>  ; CHECK-NEXT:    %call = call i32 @_Z3adji(i32 %1)
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list