Index: llvm/lib/Target/ARM/ARMInstrInfo.td =================================================================== --- llvm/lib/Target/ARM/ARMInstrInfo.td +++ llvm/lib/Target/ARM/ARMInstrInfo.td @@ -3759,6 +3759,10 @@ (QADD GPR:$a, GPR:$b)>; def : ARMV5TEPat<(ssubsat GPR:$a, GPR:$b), (QSUB GPR:$a, GPR:$b)>; +def : ARMV5TEPat<(saddsat(saddsat rGPR:$Rm, rGPR:$Rm), rGPR:$Rn), + (QDADD rGPR:$Rm, rGPR:$Rn)>; +def : ARMV5TEPat<(ssubsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)), + (QDSUB rGPR:$Rm, rGPR:$Rn)>; def : ARMV6Pat<(ARMqadd8b rGPR:$Rm, rGPR:$Rn), (QADD8 rGPR:$Rm, rGPR:$Rn)>; def : ARMV6Pat<(ARMqsub8b rGPR:$Rm, rGPR:$Rn), Index: llvm/lib/Target/ARM/ARMInstrThumb2.td =================================================================== --- llvm/lib/Target/ARM/ARMInstrThumb2.td +++ llvm/lib/Target/ARM/ARMInstrThumb2.td @@ -2399,6 +2399,10 @@ (t2QADD rGPR:$Rm, rGPR:$Rn)>; def : Thumb2DSPPat<(ssubsat rGPR:$Rm, rGPR:$Rn), (t2QSUB rGPR:$Rm, rGPR:$Rn)>; +def : Thumb2DSPPat<(saddsat(saddsat rGPR:$Rm, rGPR:$Rm), rGPR:$Rn), + (t2QDADD rGPR:$Rm, rGPR:$Rn)>; +def : Thumb2DSPPat<(ssubsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)), + (t2QDSUB rGPR:$Rm, rGPR:$Rn)>; def : Thumb2DSPPat<(ARMqadd8b rGPR:$Rm, rGPR:$Rn), (t2QADD8 rGPR:$Rm, rGPR:$Rn)>; def : Thumb2DSPPat<(ARMqsub8b rGPR:$Rm, rGPR:$Rn), Index: llvm/test/CodeGen/ARM/qdadd.ll =================================================================== --- llvm/test/CodeGen/ARM/qdadd.ll +++ llvm/test/CodeGen/ARM/qdadd.ll @@ -36,14 +36,12 @@ ; ; CHECK-T2DSP-LABEL: qdadd: ; CHECK-T2DSP: @ %bb.0: -; CHECK-T2DSP-NEXT: qadd r0, r0, r0 -; CHECK-T2DSP-NEXT: qadd r0, r0, r1 +; CHECK-T2DSP-NEXT: qdadd r0, r0, r1 ; CHECK-T2DSP-NEXT: bx lr ; ; CHECK-ARM-LABEL: qdadd: ; CHECK-ARM: @ %bb.0: -; CHECK-ARM-NEXT: qadd r0, r0, r0 -; CHECK-ARM-NEXT: qadd r0, r0, r1 +; CHECK-ARM-NEXT: qdadd r0, r0, r1 ; CHECK-ARM-NEXT: bx lr %z = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %x) %tmp = call i32 @llvm.sadd.sat.i32(i32 %z, i32 %y) @@ -82,14 +80,12 @@ ; ; CHECK-T2DSP-LABEL: qdadd_c: ; CHECK-T2DSP: @ %bb.0: -; CHECK-T2DSP-NEXT: qadd r0, r0, r0 -; CHECK-T2DSP-NEXT: qadd r0, r1, r0 +; CHECK-T2DSP-NEXT: qdadd r0, r0, r1 ; CHECK-T2DSP-NEXT: bx lr ; ; CHECK-ARM-LABEL: qdadd_c: ; CHECK-ARM: @ %bb.0: -; CHECK-ARM-NEXT: qadd r0, r0, r0 -; CHECK-ARM-NEXT: qadd r0, r1, r0 +; CHECK-ARM-NEXT: qdadd r0, r0, r1 ; CHECK-ARM-NEXT: bx lr %z = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %x) %tmp = call i32 @llvm.sadd.sat.i32(i32 %y, i32 %z) @@ -128,14 +124,12 @@ ; ; CHECK-T2DSP-LABEL: qdsub: ; CHECK-T2DSP: @ %bb.0: -; CHECK-T2DSP-NEXT: qadd r0, r0, r0 -; CHECK-T2DSP-NEXT: qsub r0, r1, r0 +; CHECK-T2DSP-NEXT: qdsub r0, r1, r0 ; CHECK-T2DSP-NEXT: bx lr ; ; CHECK-ARM-LABEL: qdsub: ; CHECK-ARM: @ %bb.0: -; CHECK-ARM-NEXT: qadd r0, r0, r0 -; CHECK-ARM-NEXT: qsub r0, r1, r0 +; CHECK-ARM-NEXT: qdsub r0, r1, r0 ; CHECK-ARM-NEXT: bx lr %z = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %x) %tmp = call i32 @llvm.ssub.sat.i32(i32 %y, i32 %z)