[PATCH] D88806: [SCEV] Model ptrtoint(SCEVUnknown) cast not as unknown, but as zext/trunc/self of SCEVUnknown

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 03:09:16 PDT 2020


lebedev.ri added a comment.

In D88806#2329676 <https://reviews.llvm.org/D88806#2329676>, @simon_tatham wrote:

> Hi @lebedev.ri , it looks as if this commit is causing an assertion failure compiling the following example code.

Hi, thank you for the test case!

>   void bar(void), baz(unsigned);
>   
>   void foo(char *d, char *s, unsigned n) {
>     if ((((unsigned)d | (unsigned)s) & 3) == 0) {
>       bar();
>     } else {
>       unsigned tmp = (unsigned)d - (unsigned)s;
>       while (n > tmp) {
>         baz(tmp);
>         n -= tmp;
>       }
>     }
>   }
>
> Compiling this with
>
>   clang --target=arm-arm-none-eabi -Os -mthumb -march=armv6s-m -S -o - repro.c
>
> causes an assertion failure:
>
>   clang: /data/statham/llvm-project/llvm/lib/Analysis/IVDescriptors.cpp:913: llvm::InductionDescriptor::InductionDescriptor(llvm::Value*, llvm::InductionDescriptor::InductionKind, const llvm::SCEV*, llvm::BinaryOperator*, llvm::SmallVectorImpl<llvm::Instruction*>*): Assertion `(IK == IK_FpInduction || Step->getType()->isIntegerTy()) && "StepValue is not an integer"' failed.
>
> Bisection suggests that this commit introduced it, and reverting this commit causes that code to compile succesfully. Any thoughts?

That is an yet another place that needs updating (because casts are implicit).
The more minimal test case is

  ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
  ; RUN: opt < %s -canon-freeze -S | FileCheck %s
  
  target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
  target triple = "thumbv6m-arm-none-eabi"
  
  declare void @widget()
  declare void @wobble(i32)
  
  define void @barney(i8* %arg, i8* %arg18, i32 %arg19) {
  bb:
    %tmp = ptrtoint i8* %arg to i32
    %tmp20 = ptrtoint i8* %arg18 to i32
    %tmp21 = or i32 %tmp20, %tmp
    %tmp22 = and i32 %tmp21, 3
    %tmp23 = icmp eq i32 %tmp22, 0
    br i1 %tmp23, label %bb24, label %bb25
  
  bb24:
    tail call void @widget()
    br label %bb34
  
  bb25:
    %tmp26 = sub i32 %tmp, %tmp20
    %tmp27 = icmp ult i32 %tmp26, %arg19
    br i1 %tmp27, label %bb28, label %bb34
  
  bb28:
    br label %bb29
  
  bb29:
    %tmp30 = phi i32 [ %tmp31, %bb29 ], [ %arg19, %bb28 ]
    tail call void @wobble(i32 %tmp26)
    %tmp31 = sub i32 %tmp30, %tmp26
    %tmp32 = icmp ugt i32 %tmp31, %tmp26
    br i1 %tmp32, label %bb29, label %bb33
  
  bb33:
    br label %bb34
  
  bb34:
    ret void
  }

Let me look a bit more..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88806/new/

https://reviews.llvm.org/D88806



More information about the llvm-commits mailing list