[llvm] [AArch64] Optimize when storing symmetry constants (PR #93717)

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 10:07:40 PDT 2024


================
@@ -93,3 +93,134 @@ define i64 @testuu0xf555f555f555f555() {
 ; CHECK-NEXT:    ret
   ret i64 u0xf555f555f555f555
 }
+
+define void @test_store_0x1234567812345678(ptr %x) {
+; CHECK-LABEL: test_store_0x1234567812345678:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    mov x8, #22136 // =0x5678
+; CHECK-NEXT:    movk x8, #4660, lsl #16
+; CHECK-NEXT:    stp w8, w8, [x0, #32]
----------------
davemgreen wrote:

I think this should still be a 0 offset, as it is storing to the same place. Can you add a test with a non-zero offset, as in this example:
```
define void @test_store_0x1234567812345678_o(ptr %x) {
; CHECK-LABEL: test_store_0x1234567812345678_o:       
; CHECK:       // %bb.0:                              
; CHECK-NEXT:    mov x8, #22136 // =0x5678            
; CHECK-NEXT:    movk x8, #4660, lsl #16              
; CHECK-NEXT:    stp w8, w8, [x0, #32]                
; CHECK-NEXT:    ret                                  
  %g = getelementptr i64, ptr %x, i64 4               
  store i64 u0x1234567812345678, ptr %g               
  ret void                                            
}  
```

I believe it needs to double the immediate from the str when generating the stp, as the first offset is multiplied by 8, the second by 4. It would be good to test other offsets too, especially the edge-cases close to the boundaries of the allowed values.

https://github.com/llvm/llvm-project/pull/93717


More information about the llvm-commits mailing list