[llvm] df05512 - [ARM] Add test for thumb2-reduce-size NFC (#112333)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 05:50:24 PDT 2024
Author: VladiKrapp-Arm
Date: 2024-10-16T13:50:19+01:00
New Revision: df0551298868b164197a4e54e9444120dc96ff53
URL: https://github.com/llvm/llvm-project/commit/df0551298868b164197a4e54e9444120dc96ff53
DIFF: https://github.com/llvm/llvm-project/commit/df0551298868b164197a4e54e9444120dc96ff53.diff
LOG: [ARM] Add test for thumb2-reduce-size NFC (#112333)
Check that t2MUL is reduced to tMUL
Added:
llvm/test/CodeGen/Thumb2/avoidmuls.mir
Modified:
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/Thumb2/avoidmuls.mir b/llvm/test/CodeGen/Thumb2/avoidmuls.mir
new file mode 100644
index 00000000000000..8d5567482d5cd7
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb2/avoidmuls.mir
@@ -0,0 +1,67 @@
+# RUN: llc -run-pass=thumb2-reduce-size %s -o - | FileCheck %s
+
+--- |
+ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+ target triple = "thumbv8m.main-arm-none-eabi"
+
+ ; Function Attrs: norecurse nounwind readnone
+ define i32 @test(i32 %x, i32 %y) local_unnamed_addr #0 {
+ entry:
+ %cmp6 = icmp sgt i32 %y, 0
+ br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
+
+ for.body.preheader: ; preds = %entry
+ br label %for.body
+
+ for.cond.cleanup: ; preds = %for.body, %entry
+ %sum.0.lcssa = phi i32 [ 1, %entry ], [ %mul, %for.body ]
+ ret i32 %sum.0.lcssa
+
+ for.body: ; preds = %for.body, %for.body.preheader
+ %lsr.iv1 = phi i32 [ %lsr.iv.next2, %for.body ], [ %x, %for.body.preheader ]
+ %lsr.iv = phi i32 [ %lsr.iv.next, %for.body ], [ %y, %for.body.preheader ]
+ %sum.07 = phi i32 [ %mul, %for.body ], [ 1, %for.body.preheader ]
+ %mul = mul nsw i32 %lsr.iv1, %sum.07
+ %lsr.iv.next = add i32 %lsr.iv, -1
+ %lsr.iv.next2 = add i32 %lsr.iv1, 1
+ %exitcond = icmp eq i32 %lsr.iv.next, 0
+ br i1 %exitcond, label %for.cond.cleanup, label %for.body
+ }
+
+ attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-m33" "target-features"="-d32,+dsp,+fp-armv8,-fp64,+hwdiv,+strict-align,+thumb-mode,-crc,-dotprod,-hwdiv-arm,-ras" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+...
+---
+name: test
+tracksRegLiveness: true
+liveins:
+ - { reg: '$r0', virtual-reg: '' }
+ - { reg: '$r1', virtual-reg: '' }
+body: |
+ bb.0.entry:
+ successors: %bb.1.for.body, %bb.2.for.cond.cleanup
+ liveins: $r0, $r1
+
+ $r2 = tMOVr $r0, 14, _
+ $r0 = t2MOVi 1, 14, _, _
+ t2CMPri $r1, 1, 14, _, implicit-def $cpsr
+ t2Bcc %bb.2.for.cond.cleanup, 11, killed $cpsr
+
+ bb.1.for.body:
+ successors: %bb.2.for.cond.cleanup, %bb.1.for.body
+ liveins: $r0, $r1, $r2
+
+ $r0 = t2MUL $r2, killed $r0, 14, _
+ $r2 = t2ADDri killed $r2, 1, 14, _, _
+ $r1 = t2SUBri killed $r1, 1, 14, _, def $cpsr
+ t2Bcc %bb.1.for.body, 1, killed $cpsr
+
+ bb.2.for.cond.cleanup:
+ liveins: $r0
+
+ tBX_RET 14, _, implicit $r0
+
+...
+# CHECK-LABEL: test
+# CHECK: tMUL
+# CHECK-NOT: t2MUL
More information about the llvm-commits
mailing list