I believe the way to implement this (and possibly similar optimizations for AREF) is to recognize the pattern:
(LET ((X (GETHASH KEY TABLE))) (IF X X (SETF (GETHASH KEY TABLE) ...)))
during IR1 optimization.
I believe the way to implement this (and possibly similar optimizations for AREF) is to recognize the pattern:
(LET ((X (GETHASH KEY TABLE)))
(IF X
X
(SETF (GETHASH KEY TABLE) ...)))
during IR1 optimization.