When the first operand is a null pointer we can avoid making a G_PTR_ADD and
make a G_INTTOPTR with the offset operand.
This helps us avoid making add with 0 later on for targets such as AMDGPU.
Details
Details
- Reviewers
arsenm foad - Commits
- rG52ba4fa6aa21: [GlobalISel] Avoid making G_PTR_ADD with nullptr
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
This is probably wrong for non integral pointers. Why not do this as a combine later? We need to start recognizing G_PTRADD (constant) + constant anyway to handle lowered LDS addresses
| llvm/test/CodeGen/AArch64/GlobalISel/translate-gep.ll | ||
|---|---|---|
| 11 ↗ | (On Diff #289930) | Can you avoid generating this unused constant in the first place? |
| llvm/lib/Target/AMDGPU/AMDGPUCombine.td | ||
|---|---|---|
| 40 ↗ | (On Diff #292192) | ptr_add |
| 40–45 ↗ | (On Diff #292192) | This should go in the generic combiner |
| llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp | ||
| 45 ↗ | (On Diff #292192) | Should not construct a local MachineIRBuilder |
| llvm/test/CodeGen/AMDGPU/GlobalISel/combine-add-nullptr.mir | ||
| 53–54 | Can simplify these out of the test | |
| 57 | Should add vector test | |
Combine the scalar and vector check above?