1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/lib
KAWASHIMA Takahiro 47186c3ead [LoopReroll] Fix rerolling loop with extra instructions
Fixes PR47627

This fix suppresses rerolling a loop which has an unrerollable
instruction.

Sample IR for the explanation below:

```
define void @foo([2 x i32]* nocapture %a) {
entry:
  br label %loop

loop:
  ; base instruction
  %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %loop ]

  ; unrerollable instructions
  %stptrx = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %indvar, i64 0
  store i32 999, i32* %stptrx, align 4

  ; extra simple arithmetic operations, used by root instructions
  %plus20 = add nuw nsw i64 %indvar, 20
  %plus10 = add nuw nsw i64 %indvar, 10

  ; root instruction 0
  %ldptr0 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus20, i64 0
  %value0 = load i32, i32* %ldptr0, align 4
  %stptr0 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus10, i64 0
  store i32 %value0, i32* %stptr0, align 4

  ; root instruction 1
  %ldptr1 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus20, i64 1
  %value1 = load i32, i32* %ldptr1, align 4
  %stptr1 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus10, i64 1
  store i32 %value1, i32* %stptr1, align 4

  ; loop-increment and latch
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond = icmp eq i64 %indvar.next, 5
  br i1 %exitcond, label %exit, label %loop

exit:
  ret void
}
```

In the loop rerolling pass, `%indvar` and `%indvar.next` are appended
to the `LoopIncs` vector in the `LoopReroll::DAGRootTracker::findRoots`
function.

Before this fix, two instructions with `unrerollable instructions`
comment above are marked as `IL_All` at the end of the
`LoopReroll::DAGRootTracker::collectUsedInstructions` function,
as well as instructions with `extra simple arithmetic operations`
comment and `loop-increment and latch` comment. It is incorrect
because `IL_All` means that the instruction should be executed in all
iterations of the rerolled loop but the `store` instruction should
not.

This fix rejects instructions which may have side effects and don't
belong to def-use chains of any root instructions and reductions.

See https://bugs.llvm.org/show_bug.cgi?id=47627 for more information.
2021-04-23 15:14:46 +09:00
..
Analysis [SCEV] Compute ranges for lshr recurrences 2021-04-22 11:06:31 -07:00
AsmParser [LLParser] Print mismatched types in error message 2021-04-21 13:10:37 -07:00
BinaryFormat
Bitcode [Bitcode] Ensure DIArgList in bitcode has no null or forward metadata refs 2021-04-22 12:03:33 +01:00
Bitstream
CodeGen [InlineSpiller] Clean-up isSpillCandBB 2021-04-23 10:16:02 +07:00
DebugInfo Fix bug in .eh_frame/.debug_frame PC offset calculation for DW_EH_PE_pcrel 2021-04-15 15:06:20 +04:00
Demangle Fix memory leak in MicrosoftDemangleNodes's Node::toString 2021-04-22 18:44:30 +02:00
DWARFLinker [dsymutil] Stop emulating dsymutil-classic CIE caching behavior 2021-04-06 20:15:41 -07:00
ExecutionEngine Revert "Allow invokable sub-classes of IntrinsicInst" 2021-04-20 15:38:38 -07:00
Extensions
FileCheck Fix PR46880: Fail CHECK-NOT with undefined variable 2021-04-20 14:42:46 +01:00
Frontend [OpenMP IRBuilder, MLIR] Add support for OpenMP do schedule dynamic 2021-04-16 16:09:49 +01:00
Fuzzer
FuzzMutate
InterfaceStub
IR [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all} 2021-04-22 18:07:30 -07:00
IRReader
LineEditor
Linker
LTO [Support] Don't include VirtualFileSystem.h in CommandLine.h 2021-04-21 10:19:01 -04:00
MC [AsmParser][ms][X86] Fix possible misbehaviour in parsing of special tokens at start of string. 2021-04-21 10:21:09 -04:00
MCA [MCA][LSUnit] Fix a potential use after free in the logic that updates memory groups. 2021-04-20 13:30:45 +01:00
Object [TextAPI] move source code files out of subdirectory, NFC 2021-04-05 10:24:42 -07:00
ObjectYAML [yaml2obj/obj2yaml/llvm-readobj] Support printing and parsing AVR-specific e_flags 2021-04-15 15:54:28 +02:00
Option
Passes [NewPM] Mark some more wrapper passes as ignored 2021-04-21 23:55:02 -07:00
ProfileData [CSSPGO][llvm-profdata] Support trimming cold context when merging profiles 2021-04-22 00:42:37 -07:00
Remarks [Support] Don't include VirtualFileSystem.h in CommandLine.h 2021-04-21 10:19:01 -04:00
Support Temporarily revert the code part of D100981 "Delete le32/le64 targets" 2021-04-22 10:18:44 -07:00
TableGen [TableGen] Add support for the 'assert' statement in multiclasses 2021-04-19 09:01:42 -04:00
Target [X86][AMX][NFC] Avoid assert for the same immidiate value 2021-04-23 12:17:00 +08:00
Testing [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN 2021-04-16 10:08:36 -04:00
TextAPI [TextAPI] move source code files out of subdirectory, NFC 2021-04-05 10:24:42 -07:00
ToolDrivers
Transforms [LoopReroll] Fix rerolling loop with extra instructions 2021-04-23 15:14:46 +09:00
WindowsManifest
XRay
CMakeLists.txt