[PATCH] [X86] Improve mul w/ overflow codegen, to MUL8+SETO.
Juergen Ributzka
juergen at apple.com
Thu Oct 23 11:14:19 PDT 2014
Hi Ahmed,
this turned out to be a very nice and simple fix. I didn't know tblgen would give you such a hard time for this one.
Please check xaluo.ll for already existing tests for {u|s}mul.with.overflow and enable them for SelectionDAG.
Thanks and LGTM.
-Juergen
================
Comment at: test/CodeGen/X86/i8-umulo.ll:26-48
@@ -24,1 +25,24 @@
}
+
+declare {i8, i1} @llvm.smul.with.overflow.i8(i8 %a, i8 %b)
+define i8 @testsmulo(i32 %argc) {
+; CHECK-LABEL: testsmulo
+; CHECK: movb $25, %al
+; CHECK: imulb [[RESULTREG:.+]]
+; CHECK: jno [[NOOVERFLOWLABEL:.+]]
+; CHECK: movb [[RESULTREG]], %al
+; CHECK: {{.*}}[[NOOVERFLOWLABEL]]:
+; CHECK: retl
+top:
+ %RHS = trunc i32 %argc to i8
+ %smul = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 25, i8 %RHS)
+ %ex = extractvalue { i8, i1 } %smul, 1
+ br i1 %ex, label %overflow, label %nooverlow
+
+overflow:
+ ret i8 %RHS
+
+nooverlow:
+ %smul.value = extractvalue { i8, i1 } %smul, 0
+ ret i8 %smul.value
+}
----------------
There are already tests for this in xaluo.ll, but they are disabled for SelectionDAG.
http://reviews.llvm.org/D5809
More information about the llvm-commits
mailing list