This is an archive of the discontinued LLVM Phabricator instance.

[PeepholeOptimizer] Don't assume bitcast def always has input
AbandonedPublic

Authored by jsji on Aug 15 2019, 10:02 AM.

Details

Reviewers
None
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/bitcast-peelhole.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.

Event Timeline

jsji created this revision.Aug 15 2019, 10:02 AM
jsji abandoned this revision.Aug 15 2019, 10:02 AM

arc command mistake.