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
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 | 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 | ||
52–53 ↗ | (On Diff #292192) | Can simplify these out of the test |
56 ↗ | (On Diff #292192) | Should add vector test |
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
2737–2740 ↗ | (On Diff #294334) | Combine the scalar and vector check above? |
2743 ↗ | (On Diff #294334) | I have a patch to generalize these checks I haven't posted yet, but I guess having the two paths is fine for now |
Can you avoid generating this unused constant in the first place?