[PATCH] D86395: InstCombine transform pattern "(~A & B) ^ A -> (A | B)" added

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 13:36:35 PDT 2020


spatel added a comment.

In D86395#2252636 <https://reviews.llvm.org/D86395#2252636>, @Jac1494 wrote:

> In D86395#2246162 <https://reviews.llvm.org/D86395#2246162>, @spatel wrote:
>
>>> If my earlier comment about the tests did not make sense, please grep for "thwart" in this test directory to see examples.
>
> A bit of clarification needed(I'm still new to this) @spatel .
> Can you please explain what is purpose of this line ?? And is this 42 value conveying something special to codegen pipeline ??

Sure - "42" represents an arbitrary value. I'm not sure if this was the original joke, but see - https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything_(42)

>   x = add i32 %p, 42 ; thwart complexity-based canonicalization
>
> And How to create this. ??  Because I have tried to create IR(test case) with optimization without this patch but i am not getting this line.

Instcombine is changing the IR before it reaches your patched code. I suggest again to step through your current "test6" in the debugger and/or run "opt -debug" to see what is happening.

The "thwart" instruction is creating an `xor` that has binops as both operands. That is required to prevent instcombine from rearranging the operands before it reaches your code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86395/new/

https://reviews.llvm.org/D86395



More information about the llvm-commits mailing list