[llvm-commits] patch: folding (zext (and x, cst))
Nick Lewycky
nicholas at mxc.ca
Tue Jun 7 02:46:27 PDT 2011
I have an unfinished patch. I was looking to optimize:
define i32 @test1(i8 %x) nounwind readnone {
%A = and i8 %x, -32
%B = zext i8 %A to i32
ret i32 %B
}
which currently does a mov into %al, then the "and", then extends, into
doing a single extending mov, then an "and" in 32-bits. The rule I
decided upon is "(zext (and x, cst)) -> (and (anyext x), (zext cst))" in
the DAG combiner.
That wasn't so hard to implement, but I haven't been able to chase down
all of the fallout. The primary problem is that any-extends are showing
up in places that didn't expect them. I added another DAG combine to
fold away an anyext in one transform with sbbl, but then got rather stuck.
The patterns added in this commit:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110502/120547.html
isn't matching any more. The relevant portion of before:
0x90580f0: i32 = X86ISD::CMP 0x9057a90, 0x9057a08
0x9057f58: i32 = X86ISD::SETCC_CARRY 0x9057fe0, 0x90580f0
0x9058068: i32 = sub 0x9057a90, 0x9057f58
and after:
0x96ff548: i32 = X86ISD::CMP 0x96feee8, 0x96fee60
0x96ff4c0: i8 = X86ISD::SETCC_CARRY 0x96ff438, 0x96ff548
0x96fef70: i32 = sign_extend 0x96ff4c0
0x96ff080: i32 = sub 0x96feee8, 0x96fef70
I'm not sure why this isn't being folded away, because
X86InstrCompiler.td has a pattern that matches anyext(X86setcc_c) and
turns it into a single X86setcc_c of the extended type. Why isn't that
firing here?
I've attached my patch and the result of running 'llc -debug
test/CodeGen/X86/add-of-carry.ll' with my patch in place.
Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dagcombine.patch
Type: text/x-patch
Size: 3990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110607/fbff2567/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: after.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110607/fbff2567/attachment.txt>
More information about the llvm-commits
mailing list