[GlobalISel] Don't select trivially dead instructions.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Sun, 19 Mar 2017 16:13:00 +0000 (16:13 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Sun, 19 Mar 2017 16:13:00 +0000 (16:13 +0000)
commit931904d7772b18210d7166ed657176ae91ad11d8
treec15a0c51ee751a03bb25cc92814a3087cefa0dba
parent48bcd22ce81dc807a1868ac4838abff06bec3f74
[GlobalISel] Don't select trivially dead instructions.

Folding instructions when selecting can cause them to become dead.
Don't select these dead instructions (if they don't have other side
effects, and don't define physical registers).

Preserve existing tests by adding COPYs.

In some tests, the G_CONSTANT vregs never get constrained to a class:
the only use of the vreg was folded into another instruction, so the
G_CONSTANT, now dead, never gets selected.

llvm-svn: 298224
15 files changed:
llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-binop.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-bitcast.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-constant.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-fp-casts.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-int-ext.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-int-ptr-casts.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-load.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-trunc.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-xor.mir
llvm/test/CodeGen/AArch64/GlobalISel/select.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-load-flat.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-load-smrd.mir
llvm/test/CodeGen/ARM/GlobalISel/arm-instruction-select.mir
llvm/test/CodeGen/X86/GlobalISel/x86_64-instructionselect.mir