@@ -5287,9 +5287,20 @@ OptimizeLongfill(IRList *irl) {
5287
5287
IR * prevset ;
5288
5288
int32_t setval ;
5289
5289
if (IsDummy (ir )) continue ;
5290
- if (ir -> opc == OPC_CALL && !CondIsSubset (COND_C ,ir -> cond ) && !strcmp (ir -> dst -> name ,"builtin_longfill_" )
5290
+ if (ir -> opc == OPC_CALL && !strcmp (ir -> dst -> name ,"builtin_longfill_" )
5291
+ && CondIsSubset (ir -> cond , (IRCond )((ir -> cond >>2 )|COND_NC ))
5291
5292
&& (prevset = FindPrevSetterForReplace (ir ,GetArgReg (1 )))
5292
5293
&& isConstMove (prevset ,& setval )) {
5294
+ //
5295
+ // The CondIsSubset(ir->cond, (ir->cond>>2)|COND_NC)
5296
+ // bit above requires explanation:
5297
+ // Some conditions can't be combined with COND_NC
5298
+ // These are ones where there are some condition states (of the 4
5299
+ // possible) that execute the original condition, but after clearing
5300
+ // C do not necessarily execute the combined condition.
5301
+ // The bitwise operation is somewhat mindbboggling but Ada
5302
+ // tested it with a script.
5303
+ //
5293
5304
int addr = ir -> addr ; // Some opts require addresses to be sorta-correct;
5294
5305
// Since we replace a funccall, we can clobber flags and args
5295
5306
IR * sub = NewIR (OPC_SUB );
@@ -5299,7 +5310,6 @@ OptimizeLongfill(IRList *irl) {
5299
5310
sub -> addr = addr ;
5300
5311
sub -> cond = ir -> cond ;
5301
5312
IR * setq = NewIR (OPC_SETQ );
5302
- setq -> cond = COND_NC ;
5303
5313
setq -> dst = GetArgReg (2 );
5304
5314
setq -> cond = (IRCond )(COND_NC | ir -> cond );
5305
5315
setq -> addr = addr ;
0 commit comments