[PATCH] D81267: [LV] Enable the LoopVectorizer to create pointer inductions

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 18:05:36 PDT 2020


rupprecht reopened this revision.
rupprecht added a comment.
This revision is now accepted and ready to land.

Hi, I had to revert this in 10c82eecbcb7 <https://reviews.llvm.org/rG10c82eecbcb7d9f000f6640b26c854843a78f091> due to crashing when building gzip (util.c). Reduced as both C and IR:

  $ cat repro.c
  void a(char* b) {
    for (char* c = 0; c != b;)
      if (*--c) *c = '_';
  }
  $ clang -cc1 -emit-obj -target-cpu x86-64 -target-feature +sse4.2 -O2 -Wall -vectorize-loops repro.c
  PHI node entries do not match predecessors!
    %pointer.phi = phi i8* [ null, %vector.ph ], [ %2, %vector.body ]
  label %vector.body
  label %vector.ph
  clang: /home/rupprecht/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8029: bool llvm::LoopVectorizePass::processLoop(llvm::Loop *): Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.      Program arguments: /home/rupprecht/dev/clang -cc1 -emit-obj -target-cpu x86-64 -target-feature +sse4.2 -O2 -Wall -vectorize-loops repro.c 
  1.      <eof> parser at end of file
  2.      Per-module optimization passes
  3.      Running pass 'Function Pass Manager' on module 'repro.c'.
  4.      Running pass 'Loop Vectorization' on function '@a'
   #0 0x0000000008912197 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:11
   #1 0x0000000008912339 PrintStackTraceSignalHandler(void*) /home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:1
   #2 0x0000000008910b4b llvm::sys::RunSignalHandlers() /home/rupprecht/src/llvm-project/llvm/lib/Support/Signals.cpp:67:5
   #3 0x0000000008912a95 SignalHandler(int) /home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:406:1
   #4 0x00007f7c948ff110 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14110)
   #5 0x00007f7c92e7a761 raise /build/glibc-M65Gwz/glibc-2.30/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
   #6 0x00007f7c92e6455b abort /build/glibc-M65Gwz/glibc-2.30/stdlib/abort.c:81:7
   #7 0x00007f7c92e6442f get_sysdep_segment_value /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:509:8
   #8 0x00007f7c92e6442f _nl_load_domain /build/glibc-M65Gwz/glibc-2.30/intl/loadmsgcat.c:970:34
   #9 0x00007f7c92e73092 (/lib/x86_64-linux-gnu/libc.so.6+0x34092)
  #10 0x0000000008adb37b llvm::LoopVectorizePass::processLoop(llvm::Loop*) /home/rupprecht/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8030:3
  
  $ cat repro.ll
  ; ModuleID = './repro.ll'
  source_filename = "repro.c"
  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-unknown-linux-gnu"
  
  ; Function Attrs: noinline nounwind
  define void @a(i8* %b) #0 {
  entry:
    %b.addr = alloca i8*, align 8
    %c = alloca i8*, align 8
    store i8* %b, i8** %b.addr, align 8
    br label %for.cond
  
  for.cond:                                         ; preds = %if.end, %entry
    %0 = load i8*, i8** %c, align 8
    %1 = load i8*, i8** %b.addr, align 8
    %cmp = icmp ne i8* %0, %1
    br i1 %cmp, label %for.body, label %for.end
  
  for.body:                                         ; preds = %for.cond
    %2 = load i8*, i8** %c, align 8
    %incdec.ptr = getelementptr inbounds i8, i8* %2, i32 -1
    store i8* %incdec.ptr, i8** %c, align 8
    %3 = load i8, i8* %incdec.ptr, align 1
    %tobool = icmp ne i8 %3, 0
    br i1 %tobool, label %if.then, label %if.end
  
  if.then:                                          ; preds = %for.body
    %4 = load i8*, i8** %c, align 8
    store i8 95, i8* %4, align 1
    br label %if.end
  
  if.end:                                           ; preds = %if.then, %for.body
    br label %for.cond
  
  for.end:                                          ; preds = %for.cond
    ret void
  }
  
  attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
  
  !llvm.module.flags = !{!0}
  
  !0 = !{i32 1, !"wchar_size", i32 4}
  $ opt -O2 repro.ll -o repro.o
  <same as above>

Reopening as the patch is reverted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81267





More information about the llvm-commits mailing list