Similar to handling existing candidate forms, this update
pattern-matches
x = a + c
y = (a + b) + c // x dominates y
and rewrites y as
y = x + b.
To be conservative, we only do this when y is the only user of (a + b).
Paths
| Differential D8898
[SLSR] simplify ternary adds by reassociation AbandonedPublic Authored by jingyue on Apr 8 2015, 9:27 AM.
Details
Diff Detail Event Timelinejingyue updated this object. Comment Actions Should this rule live inside -reassociate? Optimizing define void @reassociate(i32 %a, i32 %b, i32 %c) { %1 = add i32 %a, %c call void @foo(i32 %1) %2 = add i32 %a, %b %3 = add i32 %2, %c call void @foo(i32 %3) ret void } to define void @reassociate(i32 %a, i32 %b, i32 %c) { %1 = add i32 %a, %c call void @foo(i32 %1) %3 = add i32 %1, %b call void @foo(i32 %3) ret void } looks like a generally good idea to me. Comment Actions Hi Sanjoy, I agree the reassociation performed here is generally good, and I wish I However, I have two major concerns.
in each individual expression tree and reorders them according to their
exposed after loop unrolling, but -reassociate happens before loop Jingyue Comment Actions I am thinking of a better alternative to implement this optimization in a separate NaryReassociate pass. I'll see how that goes.
Revision Contents
Diff 23424 lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
test/Transforms/StraightLineStrengthReduce/slsr-add.ll
|