1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/CodeGen/PowerPC/bitcast-peephole.mir
Jinsong Ji af77a2caf6 [PeepholeOptimizer] Don't assume bitcast def always has input
Summary:
If we have a MI marked with bitcast bits, but without input operands,
PeepholeOptimizer might crash with assert.

eg:
If we apply the changes in PPCInstrVSX.td as in this patch:

[(set v4i32:$XT, (bitconvert (v16i8 immAllOnesV)))]>;

We will get assert in PeepholeOptimizer.

```
llvm-lit llvm-project/llvm/test/CodeGen/PowerPC/build-vector-tests.ll -v

llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:417: const
llvm::MachineOperand &llvm::MachineInstr::getOperand(unsigned int)
const: Assertion `i < getNumOperands() && "getOperand() out of range!"'
failed.
```

The fix is to abort if we found out of bound access.

Reviewers: qcolombet, MatzeB, hfinkel, arsenm

Reviewed By: qcolombet

Subscribers: wdng, arsenm, steven.zhang, wuzish, nemanjai, hiraditya, kbarton, MaskRay, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65542

llvm-svn: 369261
2019-08-19 14:19:04 +00:00

24 lines
808 B
YAML

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=powerpc64le-linux-gnu -run-pass=peephole-opt -verify-machineinstrs -o - %s | FileCheck %s
---
name: bitCast
tracksRegLiveness: true
body: |
bb.0.entry:
; CHECK-LABEL: name: bitCast
; CHECK: [[XXLEQVOnes:%[0-9]+]]:vsrc = XXLEQVOnes
; CHECK: $v2 = COPY [[XXLEQVOnes]]
; CHECK: BLR8 implicit $lr8, implicit $rm, implicit $v2
%0:vsrc = XXLEQVOnes
$v2 = COPY %0
BLR8 implicit $lr8, implicit $rm, implicit $v2
...
# This used to hit an assertion:
# llvm/include/llvm/CodeGen/MachineInstr.h:417: const
# llvm::MachineOperand &llvm::MachineInstr::getOperand(unsigned int)
# const: Assertion `i < getNumOperands() && "getOperand() out of range!"' failed.
#