Hi Richard, 在 2023/3/16 15:57, Richard Biener 写道: > So this is one way around the lack of CSE/PRE of constant operands. I'd > argue that a better spot for this _might_ be LRA (split the constant out if > there's a free register available), postreload-[g]cse (CSE the constants) and > then maybe cprop_hardreg to combine back single-use constants? > > I'm not sure if careful constraints massaging like adding magic letters to > alternatives with constants to pessimize them for LRA, making them > more expensive than spilling the constant to a register but avoid > secondary reloads with spilling a register to the stack to make room > for the constant, is possible - but in theory a special constraint modifier > for this purpose could be invented.
Thanks so much for your advice. cse/gcse doesn't take cost of constant set (the def insn of the constant) into consideration. So it won't replace the register with a constant as it costs 1 insn with the register and costs 2 insn with the constant. Finally, the single- use constants can't be back to 2 insn. Not sure if I understand it correctly. Looking forward to your advice. Thanks Gui Haochen