@@ -1560,21 +1560,40 @@ let Predicates = [HasNDD] in {
15601560}
15611561
15621562// Depositing value to 8/16 bit subreg:
1563- def : Pat<(or (and GR64:$dst, -256),
1563+ def : Pat<(or (and GR64:$dst, -256),
15641564 (i64 (zextloadi8 addr:$src))),
1565- (INSERT_SUBREG (i64 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
1565+ (INSERT_SUBREG (i64 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
15661566
1567- def : Pat<(or (and GR32:$dst, -256),
1567+ def : Pat<(or (and GR32:$dst, -256),
15681568 (i32 (zextloadi8 addr:$src))),
1569- (INSERT_SUBREG (i32 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
1569+ (INSERT_SUBREG (i32 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
15701570
1571- def : Pat<(or (and GR64:$dst, -65536),
1571+ def : Pat<(or (and GR64:$dst, -65536),
15721572 (i64 (zextloadi16 addr:$src))),
15731573 (INSERT_SUBREG (i64 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
15741574
1575- def : Pat<(or (and GR32:$dst, -65536),
1575+ def : Pat<(or (and GR32:$dst, -65536),
15761576 (i32 (zextloadi16 addr:$src))),
1577- (INSERT_SUBREG (i32 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
1577+ (INSERT_SUBREG (i32 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
1578+
1579+ // Same pattern as above but supporting `add` as the join
1580+ // operator. Need to support `add` as well, as we can convert `or` ->
1581+ // `add` when the `or` is `disjoint` (as in this patterns case).
1582+ def : Pat<(add (and GR64:$dst, -256),
1583+ (i64 (zextloadi8 addr:$src))),
1584+ (INSERT_SUBREG (i64 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
1585+
1586+ def : Pat<(add (and GR32:$dst, -256),
1587+ (i32 (zextloadi8 addr:$src))),
1588+ (INSERT_SUBREG (i32 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
1589+
1590+ def : Pat<(add (and GR64:$dst, -65536),
1591+ (i64 (zextloadi16 addr:$src))),
1592+ (INSERT_SUBREG (i64 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
1593+
1594+ def : Pat<(add (and GR32:$dst, -65536),
1595+ (i32 (zextloadi16 addr:$src))),
1596+ (INSERT_SUBREG (i32 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
15781597
15791598// To avoid needing to materialize an immediate in a register, use a 32-bit and
15801599// with implicit zero-extension instead of a 64-bit and if the immediate has at
0 commit comments