@@ -1560,21 +1560,38 @@ 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+ // We convert or -> add when the or is disjoint so need to handle for add as well.
1580+ def : Pat<(add (and GR64:$dst, -256),
1581+ (i64 (zextloadi8 addr:$src))),
1582+ (INSERT_SUBREG (i64 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
1583+
1584+ def : Pat<(add (and GR32:$dst, -256),
1585+ (i32 (zextloadi8 addr:$src))),
1586+ (INSERT_SUBREG (i32 (COPY $dst)), (MOV8rm i8mem:$src), sub_8bit)>;
1587+
1588+ def : Pat<(add (and GR64:$dst, -65536),
1589+ (i64 (zextloadi16 addr:$src))),
1590+ (INSERT_SUBREG (i64 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
1591+
1592+ def : Pat<(add (and GR32:$dst, -65536),
1593+ (i32 (zextloadi16 addr:$src))),
1594+ (INSERT_SUBREG (i32 (COPY $dst)), (MOV16rm i16mem:$src), sub_16bit)>;
15781595
15791596// To avoid needing to materialize an immediate in a register, use a 32-bit and
15801597// with implicit zero-extension instead of a 64-bit and if the immediate has at
0 commit comments